#P1771F. Hossam and Range Minimum Query
Hossam and Range Minimum Query
No submission language available for this problem.
Description
Hossam gives you a sequence of integers of length . Moreover, he will give you queries of type . For each query, consider the elements . Hossam wants to know the smallest number in this sequence, such that it occurs in this sequence an odd number of times.
You need to compute the answer for each query before process the next query.
The first line of the input contains one integer (), the length of the sequence.
The second line contains integers ().
The third line contains one integer (), the number of queries.
Each of the next lines contains two integers and (), the numbers used to encode the queries.
Let be the answer on the -th query, and be zero. Then where are parameters of the -th query and means the bitwise exclusive or operation. It is guaranteed that .
For each query, print the smallest number that occurs an odd number of times on the given segment of the sequence.
If there is no such number, print .
Input
The first line of the input contains one integer (), the length of the sequence.
The second line contains integers ().
The third line contains one integer (), the number of queries.
Each of the next lines contains two integers and (), the numbers used to encode the queries.
Let be the answer on the -th query, and be zero. Then where are parameters of the -th query and means the bitwise exclusive or operation. It is guaranteed that .
Output
For each query, print the smallest number that occurs an odd number of times on the given segment of the sequence.
If there is no such number, print .
Note
In the example,