You are given a permutation with length . You want to play a game with you friend, Bob, and the rule will be as follows:
You are given a permutation contains all numbers to . And, in queries, each query has two integers and .
For each query, you have to help Bob find the maximum value that does not exist in the subarray .
Note: A permutation is a sequence of integers from to of length containing each number exactly once.
For example, (1), (4, 3, 5, 1, 2), (3, 2, 1) are permutations and (1, 1), (4, 3, 1), (2, 3, 4) are not.
Input format
Output format
Print the maximum number that does not exist in the subarray .
Constraints
In the sample, we have a permutation (2, 3, 1, 5, 4)
the first test-case [l,r] = [1,2] so we have to find the maximum number of the array except for the subarray [1,2]
in other words, we have to find the maximum number for the subarray [3,5] which will be 5.