n,m = map(int,input().split())
#lef[i]:iの左親,ran[i]:iの左親までの距離
lef = list(range(n+1))
ran = [0]*(n+1)

#左親の発見および更新
def f(x):
    if lef[x]==x:
        return x
    lef[x] = f(lef[x])
    ran[x] = ran[x]+ran[lef[x]]
    return lef[x]

for i in range(m):
    l,r,d = map(int,input().split())
    a = f(l)
    b = f(r)
    if a == b and ran[r]-ran[l] != d:
        print("No")
        exit()
    else:
        lef[b] = a
        ran[b] = ran[l]+d-ran[r]

print("Yes")
