Problem: Copil Copac is given a list of edges describing a tree of vertices. He decides to draw it using the following algorithm:
- Step : Draws the first vertex (vertex ). Go to step .
- Step : For every edge in the input, in order: if the edge connects an already drawn vertex to an undrawn vertex , he will draw the undrawn vertex and the edge. After checking every edge, go to step .
- Step : If all the vertices are drawn, terminate the algorithm. Else, go to step .
The number of readings is defined as the number of times Copil Copac performs step .
Find the number of readings needed by Copil Copac to draw the tree.
Input Format: Each test contains multiple test cases. The first line of input contains a single integer () — the number of test cases. The description of test cases follows.
The first line of each test case contains a single integer () — the number of vertices of the tree.
The following lines of each test case contain two integers and (, ) — indicating that is the -th edge in the list. It is guaranteed that the given edges form a tree.
It is guaranteed that the sum of over all test cases does not exceed .
Output Format: For each test case, output the number of readings Copil Copac needs to draw the tree.
Note: In the first test case:
After the first reading, the tree will look like this:
After the second reading:
Therefore, Copil Copac needs readings to draw the tree.