#1214. [Ahoi2013]作业

[Ahoi2013]作业

Description

image

Format

Input

image

Output

image

Samples

3 4
1 2 2
1 2 1 3
1 2 1 1
1 3 1 3
2 3 2 3
2 2
1 1
3 2
2 1

Limitation

N=100000,M=1000000