UOJ Logo 黑暗爆炸OJ

DARKBZOJ

#1906. 树上的蚂蚁

Statistics 下载数据

Description

Input

Output

Sample Input

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

Sample Output

2

Hint

N< = 100000

Source

Play with tree By Amber