Given a tree with vertices rooted at vertex . While walking through it with her cat Chefir, Sakurako got distracted, and Chefir ran away.
To help Sakurako, Kosuke recorded his guesses. In the -th guess, he assumes that Chefir got lost at vertex and had stamina.
Also, for each guess, Kosuke assumes that Chefir could move along the edges an arbitrary number of times:
from vertex to vertex , if is an ancestor of , the stamina will not change;
from vertex to vertex , if is not an ancestor of , then Chefir's stamina decreases by .
If Chefir's stamina is , he cannot make a move of the second type.
For each assumption, your task is to find the distance to the farthest vertex that Chefir could reach from vertex , having stamina.
Vertex is an ancestor of vertex if the shortest path from to the root passes through .
输入格式
The first line contains a single integer ( ) — the number of test cases.
Each test case is described as follows:
The first line contains a single integer ( ) — the number of vertices in the tree.
The next lines contain the edges of the tree. It is guaranteed that the given edges form a tree.
The next line consists of a single integer , which denotes the number of guesses made by Kosuke.
The next lines describe the guesses made by Kosuke, with two integers , .
It is guaranteed that the sum of and the sum of across all test cases does not exceed .
输出格式
For each test case and for each guess, output the maximum distance to the farthest vertex that Chefir could reach from the starting point having stamina.