Ticket 5471
Problem 1668 -a
View hacks & all small testcases

Unable to dry run this testcase?
Try making a new request with small values of n_high, t_high, *_high, etc.


Retry
Input
9
18 2
5 16
1 16
7 2
15 13
2 13
6 10
2 1
14 10
Expected Output
34
29
-1
11
28
23
18
1
26
Generator Parameters
--row_or_col_high 20 --row_or_col_low 1 --t_high 10 --t_low 1