## TLE '16 Contest 7 P3 - NOR

View as PDF

Points: 10 (partial)
Time limit: 0.75s
Memory limit: 256M

Author:
Problem type
A Venn diagram of from the Wikimedia Commons.

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 .

1 20 ,
2 20 ,

#### 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