There exists a tree with
Constraints
Subtask 1 [20%]
All
Subtask 2 [80%]
No additional constraints.
Input Specification
The first line contains a single integer
The next
Output Specification
Output a single integer, the number of valid paths. Please note that the answer may not fit inside a 32-bit integer.
Note: You do not need to pass all sample cases to earn points on this problem.
Sample Input 1
3
1 2 4
1 3 4
Sample Output 1
3
Explanation for Sample Output 1
The three valid paths are
Sample Input 2
5
1 2 7
1 3 2
2 4 9
2 5 5
Sample Output 2
9
Sample Input 3
10
1 2 2
1 3 4
2 4 5
2 5 3
5 6 2
5 7 1
6 8 1
6 9 5
6 10 2
Sample Output 3
30
Comments