A. Bridges
time limit per test
2 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output
Examples
Input
2 1
1 2 3
Output
1
1 2 3
Input
5 9
2 1 4
3 1 2
4 3 2
5 3 3
2 3 4
4 1 2
4 3 2
1 2 4
2 1 5
Output
2
2 3 4
5 4 3
Input
3 1
1 2 1
Output
2
1 3 1
2 3 1
Input
10 16
1 6 4
2 1 9
5 2 9
3 5 2
4 3 4
9 4 7
8 9 7
10 8 2
7 8 4
2 4 9
5 2 9
5 10 9
9 10 7
9 1 8
9 10 9
2 4 10
Output
3
1 4 8
5 6 8
8 7 4