The only required knowledge is the operator. All of its possible outputs can be stored concisely in this table.
You are given a sequence consisting of 's and 's. Here, the element of is denoted with . has length , and is indexed from to .
There are queries, with each query consisting of integers and . For each query, output the value of by itself on a line. Because the operator is not associative, please evaluate the operations from left to right.
Input Specification
The first line contains one integer, .
The second line contains space-separated integers. The integer is .
The third line contains one integer, .
The following lines contain two space-separated integers, and .
Subtask | Points | Additional Constraints |
---|---|---|
1 | 20 | , |
2 | 20 | , |
3 | 60 | No additional constraints. |
Output Specification
For each query, output the result of . The operations should be evaluated from left to right.
Sample Input
6
0 1 1 0 0 1
5
1 2
2 6
3 5
4 5
5 6
Sample Output
0
0
1
1
0
Comments
How come when input is 3 5, and the A string is 0 1 1 0 0 1 the output is 1? It should process 1 0 0 which gives a value of 0 when processed with nor?