You are given a permutation A={a1,a2,a3,...aN} of N integers from 0 to N−1.
You are also given Q queries of the following two forms:
Here, MexK(aL,…,aR) = Kth smallest non-negative integer that is not available in the subarray (aL,…,aR).
You can answer the next query only when you answer the previous one. You must answer these queries online.
Input format
As you are required to respond to the queries online, the queries are encoded.
You can decode the queries as follows:
X=X′⊕LastAns,Y=Y′⊕LastAns,L=L′⊕LastAns,R=R′⊕LastAns,K=K′⊕LastAns
Here, LastAns is the last answer to the query of the second type. Initially, LastAns=0.
Output format
For each query, print the answer in a single line
Constraints
1≤N≤105
1≤Q≤2∗105
1≤X,Y≤N
1≤L≤R≤N
1≤K≤105
0≤ai<N
Initially, A = {0,3,1,2} and LastAns = 0