You are given a sequence of nonnegative integers.
The of a set of integers is the smallest nonnegative integer not contained in that set. For example, , and the of the empty set is . Repeated occurrences of the same value do not affect the .
You may repeatedly perform the following operation. For every (), replace the -th element with the of the elements at positions through . In other words, if and are the sequences before and after one operation, then
All elements change simultaneously using the values before the operation. When , the prefix is empty, so the new value is .
For example, applying one operation to produces . To determine the third new element, use , the first two elements before the operation.
There are queries. Each query consists of two integers and asks for the value at position after applying operations to the original sequence. All queries are independent, and answering a query does not change the original sequence.
Find the answer to each query.
The input is given in the following format.
Answer the queries of each test case in their given order. For each query, print the value at position after applying operations to the original sequence on one line.
After one, two, and three operations, the sequences are , , and , respectively.
The first line contains the number of test cases . Each test case is given in the following format.
The first line contains the sequence length and the number of queries , separated by a space.
The second line contains the elements , separated by spaces.
The -th of the next lines contains two integers describing the -th query, separated by a space.
| 2 | 27 | . |
| 3 | 55 | No additional constraints. |
Queries need not be given in increasing order of operation count. Each query always starts from the original sequence.
In the first test case, the only element is always after the first operation.
In the second test case, the sequence remains unchanged after every operation.
In the first test case, the successive sequences are , , and .
In the second test case, all elements become after the first operation.