You are given an array consisting of integers, and queries to it. -th query is denoted by two integers and . For each query, you have to find any integer that occurs exactly once in the subarray of from index to index (a subarray is a contiguous subsegment of an array). For example, if , then for query the subarray we are interested in is , and possible answers are , and ; for query the subarray we are interested in is , and there is no such element that occurs exactly once.
Can you answer all of the queries?
The first line contains one integer ().
The second line contains integers ().
The third line contains one integer ().
Then lines follow, -th line containing two integers and representing -th query ().
Answer the queries as follows:
If there is no integer such that it occurs in the subarray from index to index exactly once, print . Otherwise print any such integer.
6
1 1 2 3 2 4
2
2 6
1 2
4
0