The goblin kingdom is strictly hierarchical: goblin 00 is the king, and every other goblin has exactly one superior. Indra is still infiltrating their ranks, and as his fairy godmother you need to answer questions about who sits above whom.

Each query asks: if Indra is goblin vv, who is the kk-th superior above him? The 11-st superior is his direct boss, the 22-nd superior is that boss's boss, and so on. If he does not have kk superiors above him, report that the climb fails.

Input

The first line contains two integers nn and qq: the number of goblins and the number of queries.

The next n−1n-1 lines each contain two integers aa and bb, meaning that goblin aa is the superior of goblin bb.

Finally, the next qq lines each contain two integers vv and kk, representing one query.

Output

For each query, output a single integer on its own line: the kk-th superior of goblin vv, or -1 if no such superior exists.

Constraints

  • 1≤n≤1051 \le n \le 10^5
  • 1≤q≤1051 \le q \le 10^5
  • 0≤a,b,v≤n−10 \le a, b, v \le n-1
  • 1≤k≤1091 \le k \le 10^9
  • The superiors form a tree rooted at goblin 00

Example 1

Input 1
5 4
0 1
0 2
1 3
1 4
3 1
3 2
4 3
0 1
Output 1
1
0
-1
-1
Explanation
  • Goblin 33's first superior is 11.
  • Goblin 33's second superior is 00 (the king).
  • Goblin 44 has only two superiors (11 then 00), so a climb of 33 fails.
  • Goblin 00 has no superiors at all.

Comments0


No comments yet

Be the first to comment.

New comment


Log in to join the discussion.