#arc090b. [arc090_b]People on a Line

[arc090_b]People on a Line

Problem Statement

There are NN people standing on the xx-axis. Let the coordinate of Person ii be xix_i. For every ii, xix_i is an integer between 00 and 10910^9 (inclusive). It is possible that more than one person is standing at the same coordinate.

You will given MM pieces of information regarding the positions of these people. The ii-th piece of information has the form (Li,Ri,Di)(L_i, R_i, D_i). This means that Person RiR_i is to the right of Person LiL_i by DiD_i units of distance, that is, xRixLi=Dix_{R_i} - x_{L_i} = D_i holds.

It turns out that some of these MM pieces of information may be incorrect. Determine if there exists a set of values (x1,x2,...,xN)(x_1, x_2, ..., x_N) that is consistent with the given pieces of information.

Constraints

  • 1leqNleq1001 \\leq N \\leq 100 000000
  • 0leqMleq2000 \\leq M \\leq 200 000000
  • 1leqLi,RileqN1 \\leq L_i, R_i \\leq N (1leqileqM1 \\leq i \\leq M)
  • 0leqDileq100 \\leq D_i \\leq 10 000000 (1leqileqM1 \\leq i \\leq M)
  • LineqRiL_i \\neq R_i (1leqileqM1 \\leq i \\leq M)
  • If ineqji \\neq j, then (Li,Ri)neq(Lj,Rj)(L_i, R_i) \\neq (L_j, R_j) and (Li,Ri)neq(Rj,Lj)(L_i, R_i) \\neq (R_j, L_j).
  • DiD_i are integers.

Input

Input is given from Standard Input in the following format:

NN MM L1L_1 R1R_1 D1D_1 L2L_2 R2R_2 D2D_2 :: LML_M RMR_M DMD_M

Output

If there exists a set of values (x1,x2,...,xN)(x_1, x_2, ..., x_N) 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 (x1,x2,x3)(x_1, x_2, x_3) are (0,1,2)(0, 1, 2) and (101,102,103)(101, 102, 103).


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, x3x1=2x_3 - x_1 = 2 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