Problem Statement
Shawn is smart,innovative and hardworking.He has managed to program an app which helps us to communicate any people throughout the universe.This made Bebe,a girl from other planet,fall in love with him.She decides to meet him only when he solves the following statement.He needs your help !!
You are given an array A of N elements.All elements are distinct .You are also given an integer K.
You have been given Q queries.Each of those queries consists of L and R.
For each of those queries find the minimum/smallest (starting from 1) missing number in an array from range L to R which is strictly greater than K .
Constraints :
Input
First line contains N and K , implies size of the array and K as explained above.
Next line follows N integers which implies elements of an array.
Then next line contains value Q which is total number of queries to be performed.
Then each of the next Q lines contains L and R.
Output
For each query print the required answer as explained.
Note : Count of missing number always starts from 1 .
Here N=6 , K=2
So for query 1 :
All elements from index 1 to 5 are 9,1,2,3,4.
Elements not present(missing) here are 5,6,7,8,10,11,12......so on.
Hence smallest possible missing number greater than 2 is 5.
for query 2 :
All elements from index 3 to 4 are 2 and 3.
Elements not present(missing) here are 1,4,5,6,7,8,9,10,11,12......so on.
Hence smallest possible missing number greater than 2 is 4.