#arc090b. [arc090_b]People on a Line
[arc090_b]People on a Line
Problem Statement
There are people standing on the -axis. Let the coordinate of Person be . For every , is an integer between and (inclusive). It is possible that more than one person is standing at the same coordinate.
You will given pieces of information regarding the positions of these people. The -th piece of information has the form . This means that Person is to the right of Person by units of distance, that is, holds.
It turns out that some of these pieces of information may be incorrect. Determine if there exists a set of values that is consistent with the given pieces of information.
Constraints
- ()
- ()
- ()
- If , then and .
- are integers.
Input
Input is given from Standard Input in the following format:
Output
If there exists a set of values that is consistent with all given pieces of information, print Yes
; if it does not exist, print No
.
Sample Input 1
3 3
1 2 1
2 3 1
1 3 2
Sample Output 1
Yes
Some possible sets of values are and .
Sample Input 2
3 3
1 2 1
2 3 1
1 3 5
Sample Output 2
No
If the first two pieces of information are correct, holds, which is contradictory to the last piece of information.
Sample Input 3
4 3
2 1 1
2 3 5
3 4 2
Sample Output 3
Yes
Sample Input 4
10 3
8 7 100
7 9 100
9 8 100
Sample Output 4
No
Sample Input 5
100 0
Sample Output 5
Yes