#P1984E. Shuffle

Shuffle

No submission language available for this problem.

Description

Two hungry red pandas, Oscar and Lura, have a tree TT with nn nodes. They are willing to perform the following shuffle procedure on the whole tree TT exactly once. With this shuffle procedure, they will create a new tree out of the nodes of the old tree.

  1. Choose any node VV from the original tree TT. Create a new tree T2T_2, with VV as the root.
  2. Remove VV from TT, such that the original tree is split into one or more subtrees (or zero subtrees, if VV is the only node in TT).
  3. Shuffle each subtree with the same procedure (again choosing any node as the root), then connect all shuffled subtrees' roots back to VV to finish constructing T2T_2.

After this, Oscar and Lura are left with a new tree T2T_2. They can only eat leaves and are very hungry, so please find the maximum number of leaves over all trees that can be created in exactly one shuffle.

Note that leaves are all nodes with degree 11. Thus, the root may be considered as a leaf if it has only one child.

The first line contains a single integer tt (1t1041 \leq t \leq 10^4) — the number of test cases.

The first line of every test case contains a single integer nn (2n21052 \leq n \leq 2 \cdot 10^5) — the number of nodes within the original tree TT.

The next n1n - 1 lines each contain two integers uu and vv (1u,vn1 \leq u, v \leq n) — an edge within the original tree TT. The given edges form a tree.

The sum of nn over all test cases does not exceed 31053 \cdot 10^5.

For each test case, output a single integer — the maximum number of leaves achievable with exactly one shuffle procedure on the whole tree.

Input

The first line contains a single integer tt (1t1041 \leq t \leq 10^4) — the number of test cases.

The first line of every test case contains a single integer nn (2n21052 \leq n \leq 2 \cdot 10^5) — the number of nodes within the original tree TT.

The next n1n - 1 lines each contain two integers uu and vv (1u,vn1 \leq u, v \leq n) — an edge within the original tree TT. The given edges form a tree.

The sum of nn over all test cases does not exceed 31053 \cdot 10^5.

Output

For each test case, output a single integer — the maximum number of leaves achievable with exactly one shuffle procedure on the whole tree.

Sample Input 1

4
5
1 2
1 3
2 4
2 5
5
1 2
2 3
3 4
4 5
6
1 2
1 3
1 4
1 5
1 6
10
9 3
8 1
10 6
8 5
7 8
4 6
1 3
10 1
2 7

Sample Output 1

4
3
5
6

Note

In the first test case, it can be shown that the maximum number of leaves is 44. To accomplish this, we can start our shuffle with selecting node 33 as the new root.

Next, we are left only with one subtree, in which we can select node 22 to be the new root of that subtree.
This will force all 33 remaining nodes to be leaves, and once we connect them back to our new root, the shuffled subtree looks like this:
We connect the shuffled subtree back to our new root of our new tree. Our final tree has four leaves (including the root), and looks like this:

In our second test case, we have a line of five nodes. It can be shown that the maximum number of leaves after one shuffle is 33. We can start off with node 22, which forces node 11 to become a leaf. Then, if we select node 44 on the right side, we will also have nodes 33 and 55 as leaves.

The third test case is a star graph with six nodes. The number of leaves cannot increase, thus our answer will be 55 (if we start the shuffling with the original root node).