You are playing a game consisting of planets. Each planet has a teleporter to another planet (or the planet itself).
Your task is to process queries of the form: when you begin on planet and travel through teleporters, which planet will you reach?
The first line has two integers and q\:(1 \le n, q \le 2 \cdot 10^5): the number of planets and queries. The planets are numbered 1, 2, \dots , n.
The second line has integers t_1, t_2, \dots, t_n\:(1 \le t_i \le n): for each planet, the destination of the teleporter. It is possible that t_i = i.
Finally, there are lines describing the queries. Each line has two integers x\:(1 \le x \le n) and k\:(0 \le k \le 10^9): you start on planet and travel through teleporters.
Print the answer to each query.
Example 1