import sys
sys.setrecursionlimit(10**6)

N,M=map(int,input().split())

P=[i for i in range(N+1)]
r=[0 for i in range(N+1)]

def find(a):
    if a==P[a]:
        pass
    else:
        return find(P[a])
        
def union(a,b,c):
    P[b]=P[a]
    r[b]=c
    
def find2(a,b):
    if a==P[a]:
        return b+r[a]
    else:
        return find2(P[a],b+r[a])
L=[]
for i in range(M):
    a,b,c=map(int,input().split())
    union(a,b,c)
    L.append([a,b,c])
    
for i in range(1,N+1):
    r[i]=find2(i,0)
    
#print(L)

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