Company Queries I#11598

Company Queries I

1 second
128 megabytes
Medium

A company has employees, who form a tree hierarchy where each employee has a boss, except for the general director.

Your task is to process queries of the form: who is employee 's boss levels higher up in the hierarchy?

Input

The first line has two integers and : the number of employees and queries. The employees are numbered 1, 2, ..., n, and employee is the general director.

The next line has n - 1 integers e_2, e_3, ..., e_n: for each employee 2, 3, ..., n their boss.

Finally, there are lines describing the queries. Each line has two integers and : who is employee 's boss levels higher up?

Output

Print the answer for each query. If such a boss does not exist, print .

Examples

Example 1

Loading
Loading