405844: GYM102134 E Kth subtree
Description
Legends for tasks are different. There are long or short. There are boring or funny. There are understandable or not. You decide what this. Given a tree from n vertices. Also given are q queries. One query is a pair of numbers v and k. We choose v as a root and write down the sizes of the subtrees of each vertex of the tree in the nondecreasing order. The answer to the query is the k th number in this list.
InputThe first line of input contains two numbers - n and q (1 ≤ n ≤ 105, 1 ≤ q ≤ 105). Each of the following n - 1 rows contains a description of the edge of the tree - its ends ui and vi (1 ≤ ui, vi ≤ n) Each of the following q lines contains a description of the next query - the numbers vi and ki (1 ≤ vi, ki ≤ n)
OutputOutput a response to each of the requests on a separate line.
ExampleInput5 5Output
1 2
1 3
1 4
4 5
2 5
1 3
4 4
2 3
2 2
5
1
3
2
1