1906 - 树上的蚂蚁

Input

Output

Examples

Input

1
3
1 2 1
2 3 1
3
1 3 2
3 1 1
1 2 3

Output

2

Hint

N< = 100000

Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题