403292: GYM101102 L Starry Night
Description
Reem likes to look up into the night sky and count how many stars there are. The sky is represented as a tree, and a star is a fixed node with three or more rays of possibly varying lengths leading out of it. A ray is a chain of connected nodes where each node except for the last one is connected to exactly two nodes, and the last one is connected to exactly one node.
The first line of input contains a single integer T, the number of test cases.
The first line of each test case contains a single integers N (1 ≤ N ≤ 105), the number of nodes in the sky.
Each of the next N - 1 lines contains two integers a and b (1 ≤ a, b ≤ N), and represents a link that connects two nodes.
It is guaranteed that the given graph is a tree.
OutputFor each test case, print the maximum number of stars Reem can get after removing zero or more nodes, on a single line.
ExampleInput1Output
9
1 2
3 2
5 1
3 7
1 4
3 8
1 6
3 9
2Note
A tree is an undirected graph with exactly one path between any two nodes.