You are given an undirected tree of
Compute all good nodes.
Constraints
In tests worth 5 marks,
Input Specification
The first line contains a single integer
Each of the next
Output Specification
On the first line, print
For each of the next
Sample Input 1
Copy
8
1 3 1
2 3 1
3 4 3
4 5 4
5 6 3
6 7 2
6 8 2
Sample Output 1
Copy
4
3
4
5
6
Sample Input 2
Copy
8
1 2 2
1 3 1
2 4 3
2 7 1
3 5 2
5 6 2
7 8 1
Sample Output 2
Copy
0
Sample Input 3
Copy
9
1 2 2
1 3 1
1 4 5
1 5 5
2 6 3
3 7 3
4 8 1
5 9 2
Sample Output 3
Copy
5
1
2
3
6
7
Sample Input 4
Copy
10
9 2 1
9 3 1
9 4 2
9 5 2
9 1 3
9 6 4
1 8 5
1 10 5
6 7 9
Sample Output 4
Copy
4
1
6
7
9
Comments