Write a program to print the longest distance between two nodes of the given tree.
Write a program to print the longest distance between two nodes of the given tree.
The first line will be an integer T (1≤T≤10), which is the number of test cases.
For each test data:
The first line contains two integers N (1≤N≤10^5) — the number of the nodes.
Each of the next N - 1 lines contain two integers a and b, which means there is an edge between node a and b.
For each case, please print the longest distance between any two nodes of the given tree.
1
8
1 4
1 3
4 2
2 7
3 5
3 6
6 8
6