#3405. [Violet 6]故乡的梦

[Violet 6]故乡的梦

Description

Format

Input

Output

Samples

6 7
1 2 1
2 3 1
3 4 2
4 5 1
5 6 1
1 3 3
4 6 3
1 6
4
1 2
1 3
4 3
6 5
7
6
Infinity
7

Limitation