spoj#ADALEMON. Ada and Lemon 1
Ada and Lemon 1
As you might already know, Ada the Ladybug is a farmer. She grows a lemon tree. She wants to pick exactly one lemon (which grows on every leaf of the tree). She is wondering how many distinct trees will remain after harvesting exactly one lemon. Tree is different if they are distinct for each permutation of node labels.
Note that a single node is counted as leaf too.
Input
The first line of input will contain 1 ≤ T ≤ 100, the number of test-cases.
Each of the testcases will contain single integer N, the size of tree.
The next N-1 lines will contain two integers 0 ≤ a, b < N, a ≠ b, the edges of tree.
The sum of N over all test-cases will not exceed 3000.
Output
For each test-case output the number of distinct trees after harvesting exactly one lemon.
Example Input
5 4 0 1 0 2 0 3 4 0 1 1 3 3 2 6 0 2 1 2 2 3 3 5 3 4 7 1 2 0 1 2 3 2 4 3 5 6 5 9 0 1 1 2 2 3 3 4 4 5 2 6 3 7 4 8
Example Output
1 1 1 3 4
Example Input 2
1 11 6 1 3 6 4 3 2 3 0 6 5 2 10 4 8 1 7 10 9 0
Example Output 2
3