import sys
import copy
sys.setrecursionlimit(10**6)
N,M=map(int,input().split())

D=[]
P=[[i,0]for i in range(N+1)]
C=[1 for i in range(N+1)]
A=[0]

for i in range(M):
    l,r,d=map(int,input().split())
    P[r]=[l,d]
    D.append([l,r,d])
#print(P)
def find(a,b):
    if c[a]==0:
        return a,b
    elif a==P[a][0]:
        return a,b
    else:
        c[a]=0
        return find(P[a][0],b+P[a][1])
for i in range(1,N+1):
    c=copy.deepcopy(C)
    A.append(find(i,0))
#print(A)
for i in range(M):
    if A[D[i][1]][1]-A[D[i][0]][1]!=D[i][2]:
        print("No")
        exit()
print("Yes")
