#ds305. mex
mex
Mex
Problem Description
You have an array of length .
You must answer queries. Each query gives an interval and asks for the smallest natural number that does not appear in this interval.
Input Format
The first line contains two numbers ().
The next line contains numbers ().
The next lines each contain two integers ().
Output Format
For each query, output one number on a single line, the answer.
Sample Input
5 5
2 1 0 2 1
3 3
2 3
2 4
1 2
3 5
Sample Output
1
2
3
0
3