from collections import deque
N, M = map(int, raw_input().split())
A = {}
for i in xrange(M):
    L, R, D = map(int, raw_input().split())
    if not L in A:
        A[L]=[]
    A[L].append((R,D))
    if not R in A:
        A[R]=[]
    A[R].append((L,-D))
K = set(A.keys())
x = {}
ans = "Yes"
while len(K)>0:
    i = list(K)[0]
    K.remove(i)
    x[i] = 0
    q = deque([i])
    while len(q)>0:
        j = q.pop()
        for u,v in A[j]:
            if u in x and x[u]!=x[j]+v:
                ans="No"
            x[u]=x[j]+v
            if u in K:
                K.remove(u)
                q.append(u)
print ans