#def fun():


[N,M]=map(int,raw_input().split())
A={}
B={}
for i in range(1,N+1):
    A[i]=[]
    B[i]=[]
bignum=-100000000000
C=[bignum for x in range(N+1)]
for i in range(M):
    [L,R,D]=map(int,raw_input().split())
    A[L].append([R,D])
    A[R].append([L,-D])
K=A.keys()
E=[]
flg=1
while len(K)!=0 or len(E)!=0:
    if len(E)==0:
        k=K.pop(0)
        C[k]=0
    else:
        k=E.pop(0)
    a=A[k]+B[k]
    for aa in a:
        [n,d]=aa
        if C[n]!=bignum and C[n]!=C[k]+d:
            print "No"
            flg=0
        else:
            C[n]=C[k]+d
        if n in K:
            K.remove(n)
            E.append(n)
    if not flg:
        break
    #print k,C,E
if flg:
    print "yes"
#print C
