ADALEMON  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 testcases.
Each of the testcases will contain single integer N, the size of tree.
The next N1 lines will contain two integers 0 ≤ a, b < N, a ≠ b, the edges of tree.
The sum of N over all testcases will not exceed 3000.
Output
For each testcase 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
hide comments
morass:
20171027 14:33:14
@Min_25: Well yes.. at least I agree it would be a good manner to mention it so thank you, I'll add it to the statement ^_^ Have Nice Day! 

Min_25:
20171027 11:10:42
@Morass

Added by:  Morass 
Date:  20171026 
Time limit:  3s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All 