#abc235c. [abc235_c]The Kth Time Query

[abc235_c]The Kth Time Query

Problem Statement

We have a sequence of NN numbers: A=(a1,a2,dots,aN)A = (a_1, a_2, \\dots, a_N).
Process the QQ queries explained below.

  • Query ii: You are given a pair of integers (xi,ki)(x_i, k_i). Let us look at the elements of AA one by one from the beginning: a1,a2,dotsa_1, a_2, \\dots Which element will be the kik_i-th occurrence of the number xix_i?
    Print the index of that element, or \-1\-1 if there is no such element.

Constraints

  • 1leqNleq2times1051 \\leq N \\leq 2 \\times 10^5
  • 1leqQleq2times1051 \\leq Q \\leq 2 \\times 10^5
  • 0leqaileq1090 \\leq a_i \\leq 10^9 (1leqileqN)(1 \\leq i \\leq N)
  • 0leqxileq1090 \\leq x_i \\leq 10^9 (1leqileqQ)(1 \\leq i \\leq Q)
  • 1leqkileqN1 \\leq k_i \\leq N (1leqileqQ)(1 \\leq i \\leq Q)
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN QQ a1a_1 a2a_2 dots\\dots aNa_N x1x_1 k1k_1 x2x_2 k2k_2 vdots\\vdots xQx_Q kQk_Q

Output

Print QQ lines. The ii-th line should contain the answer to Query ii.


Sample Input 1

6 8
1 1 2 3 1 2
1 1
1 2
1 3
1 4
2 1
2 2
2 3
4 1

Sample Output 1

1
2
5
-1
3
6
-1
-1

11 occurs in AA at a1,a2,a5a_1, a_2, a_5. Thus, the answers to Query 11 through 44 are 1,2,5,11, 2, 5, -1 in this order.


Sample Input 2

3 2
0 1000000000 999999999
1000000000 1
123456789 1

Sample Output 2

2
-1