Problem E: 弹珠游戏(2023-T5)
Memory Limit:128 MB
Time Limit:1.000 S
Judge Style:Text Compare
Creator:
Submit:2
Solved:1
Description

Input

Output

Sample Input Copy
3
2 3 1
7
1 1
1 2
2 1
1 2
1 1
2 2
1 2
Sample Output Copy
-1
-1
1
1
2
HINT
【输入样例2】
5
0 3 5 3 4
6
1 1
1 2
2 4
1 2
2 3
1 2
【输出样例2】
1
-1
4
3