"""
Example: 

from/to
1 [ -  1  2]
2 [-1  -  1]
3 [-2 -1  -]
"""

N, M = [int(x) for x in input().split()]


to_list = [{} for _ in range(N)]
for _ in range(M):
    L, R, D = [int(x) for x in input().split()]
    L = L - 1
    R = R - 1
    if (L, R) in to_list[R].keys() and to_list[R][(L, R)] != D:
        print("No")
        exit()
    if (R, L) in to_list[L].keys() and to_list[L][(R, L)] != -D:
        print("No")
        exit()

    to_list[R][(L, R)] = D
    to_list[L][(R, L)] = -D

    for k, v in to_list[L].items():
        _L, _ = k
        to_list[R][(_L, R)] = D + v

    for k, v in to_list[R].items():
        _R, _ = k
        to_list[L][(_R, L)] = -D + v

# print(to_list)
print("Yes")
