501000033 - 树上路径

Input

Output

Examples

Input

3 2
1 1
1 2 3
2 3 3

Output

2
3

Input

4 1
1 2 3
1 2 3

Output

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