#P1796E. Colored Subgraphs
Colored Subgraphs
No submission language available for this problem.
Description
Monocarp has a tree, consisting of vertices.
He is going to select some vertex and perform the following operations on each vertex from to :
- set equal to the distance from to (the number of edges on the shortest path);
- color some color.
A nice coloring satisfies two conditions:
- for each pair of vertices of the same color , there exists a path from to that only visits vertices of the same color;
- for each pair of vertices of the same color , .
Note that Monocarp can choose any amount of different colors he wants to use.
For each used color, he then counts the number of vertices of this color. The cost of the tree is the minimum of these numbers.
What can be the maximum cost of the tree?
The first line contains a single integer () — the number of testcases.
The first line of each testcase contains a single integer () — the number of vertices in the tree.
Each of the next lines contains two integers and () — the description of an edge.
The given edges form a tree. The sum of over all testcases doesn't exceed .
For each testcase print a single integer — the maximum possible cost of the tree.
Input
The first line contains a single integer () — the number of testcases.
The first line of each testcase contains a single integer () — the number of vertices in the tree.
Each of the next lines contains two integers and () — the description of an edge.
The given edges form a tree. The sum of over all testcases doesn't exceed .
Output
For each testcase print a single integer — the maximum possible cost of the tree.