spoj#AKVOD05. Ross generates Data
Ross generates Data
Ross wants to complete the data set for his next research work. He has to generate a set of “N” non negative integers. He already knows the first “K” values out of them. He knows how to generate the remaining values. Any of the remaining values will be the minimum non negative integer that does not exist in the previous “K” values.
For example, let the value of “N” is 7 and the value of “K” be 4 and the first “K” values be 0 4 3 2 then the next 3 values will be 1 0 4.
You just have to generate the “N”th value for his work.
Input
The first line will contain "T", the no. of test cases. Then "T" test cases follows. For each test case, the first line will contain two integers "N" and "K". The next line will contain "K" integers denoting the "K" values that he already knows.
Output
For each test case, output a single integer value that denotes the "N"th integer in his data set.
Constraints
1 <= T <= 10
1 <= K <= 10^5
K < N <= 10^8
0 <= Each of the first K values <= 10^8
Example
Input:
2
7 4
0 4 3 2
8 5
4 7 2 3 0Output:
4
5