Жишээ тэстүүд

Оролт
6 6
1 2 2 1 2
2 3 1 3
3 4 2 4 5
4 5 0
5 3 1 3
6 1 1 6
Гаралт
4
6 1 2 3
Оролт
6 6
1 2 2 1 2
2 3 1 3
3 4 2 4 5
4 5 0
5 3 1 3
6 1 1 6
Гаралт
1
2
1
1
2
1
1
2
1
1
2
1

Тэмдэглэл

The input in both samples are the same. The first sample contains the answer to the first subproblem, the second sample contains the answer to the second subproblem.