A country consists of N cities that are represented as a tree graph. A tree graph is an undirected acyclic graph.
The leaders of the country decided to hold Q meetings. For the ith meeting, there are Ki leaders in different cities. For each meeting, the leaders want to find a city such that the maximum distance between any of the Ki cities and a selected city is minimum.
Note: This city does not have to be a part of the Ki cities.
Your task is to determine the minimum of the maximum distances obtained between the Ki cities and the selected city.
Input format
Output format
Print Q lines, each line contains the value that represents the minimum of the maximum distance between all the Ki cities and the city selected.
Constraints
1≤N,Q≤3×1051≤u,v≤N1≤Xi≤N∑Qi=1Ki≤N
Queries as in order:
Here is a picture of the tree for further clarity: