B. Growing Cucumbers (cucumber)
time limit per test
2 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output
Examples
Input
2
11 41
8
2 1
-1 -1
Output
11 19
Input
3
10 32123432332 4322214322123
71 22
1 2 3
-1 1 -1
Output
10 1 23
Input
10
4 14 12 6 12 19 12 18 18 1
3 2 0 8 7 3 0 2 9
3 10 1 8 2 9 6 4 7 5
1 -1 -1 1 1 -1 1 -1 1 1
Output
4 1 1 1 1 1 1 1 3 1