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
时间限制 1 秒
内存限制 512 MB
统计
上一题 下一题