Score : $300$ points
We have a sequence of $N$ numbers: $A = (a_1, a_2, \dots, a_N)$.
Process the $Q$ queries explained below.
Input is given from Standard Input in the following format:
$N$ $Q$ $a_1$ $a_2$ $\dots$ $a_N$ $x_1$ $k_1$ $x_2$ $k_2$ $\vdots$ $x_Q$ $k_Q$
Print $Q$ lines. The $i$-th line should contain the answer to Query $i$.
6 8 1 1 2 3 1 2 1 1 1 2 1 3 1 4 2 1 2 2 2 3 4 1
1 2 5 -1 3 6 -1 -1
$1$ occurs in $A$ at $a_1, a_2, a_5$. Thus, the answers to Query $1$ through $4$ are $1, 2, 5, -1$ in this order.
3 2 0 1000000000 999999999 1000000000 1 123456789 1
2 -1