I. Seesaw
time limit per test
1 second
memory limit per test
1024 megabytes
input
standard input
output
standard output
Example
Input
4
3
1 1 3
2 2 2
3
1 1 1
2 2 2
3
1 1 1
4 2 2
3
3 3 3
2 2 2
Output
0
1
2
-1