## Wesley's Anger Contest 3 Problem 4 - Canadian Construction Crew

View as PDF

Points: 12 (partial)
Time limit: 1.0s
Python 3.0s
Memory limit: 256M

Author:
Problem type

There may be multiple roads between two intersections, but there will not be a road between an intersection and itself.

#### Constraints

For this question, Python users are recommended to use PYPY over CPython.

For this problem, you will be required to pass all the samples in order to receive any points. In addition, you must pass all previous subtasks to earn points for a specific subtask.

#### Input Specification

The first line of input contains integers, and , representing the number of intersections in the city, and the number of days where requirements will be given.

The next lines describe the requirements. Each line contains integers, , , , indicating that on the day, a new road is required to be paved exactly times between intersections , and .

#### Output Specification

Output lines. On the line, output YES if it is possible to use the road paver machine to satisfy all requirements up to and including the day. Otherwise, output NO.

#### Sample Input 1

2 2
1 2 2
2 1 1

#### Sample Output 1

YES
YES

#### Sample Explanation 1

On the first day, the road paving machine can take the path .

On the second day, the road paving machine can take the path .

#### Sample Input 2

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

#### Sample Output 2

YES
NO
YES
YES

#### Sample Explanation 2

On the first day, the road paving machine can take the path .

On the second day, the road paving machine cannot take any path to pave both roads.

On the third day, the road paving machine can take the path .

On the fourth day, the road paving machine can take the path .