13696 - DS_2022_Quiz_Tree   

Description

As the horticulturalist (園藝家), you are good at planting the trees.
 
Today, each tree has an acceptable price if the size of it is large enough.
 
Given the tree T with n nodes, you are asked to discover the value x, i.e., the maximum distance between two nodes in T, as the tree price.

 

Input

The first line contains a single integer t (1 < t < 10), which is the number of test cases.
 
In each test case, the first input line contains an integer n: the number of nodes. The nodes are numbered 1,2,…,n (1 < n < 200000).
 
There are n−1 lines describing the edges. Each line contains two integers a and b: there is an edge between nodes a and b, with distance 1.

Output

Print the tree price of each test case.

 

Sample Input  Download

Sample Output  Download

Tags




Discuss