N,M=map(int,input().split())
P=[i for i in range(N+1)]
L=[0 for i in range(N+1)]
Q=[]
def find(a):
    if P[a]==a:
        return a
    else:
        return find(P[a])

def union(b,c,d):
    B=find(b)
    C=find(c)
    P[C]=P[B]
    L[c]=L[b]+d

for i in range(M):
    l,r,d=map(int,input().split())
    Q.append([l,r,d])
    union(l,r,d)
#print(P)
#print(L)

for i in Q:
    if L[i[1]]-L[i[0]]==i[2]:
        continue
    else:
        print("No")
        exit()
print("Yes")