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

x=[0 for _ in range(N)]
gp=[i for i in range(N)]

for _ in range(M):
    l,r,d=map(int,input().split())
    if(gp[l-1]==gp[r-1]):
        if(x[r-1]-x[l-1]!=d):
            print('No')
            break
    else:
        if(gp.count(gp[l-1])<gp.count(gp[r-1])):
            from_gp=gp[l-1]
            to_gp=gp[r-1]
        else:
            from_gp=gp[l-1]
            to_gp=gp[r-1]
        r_gp=gp[r-1]
        l_x=x[l-1]
        for i in range(M):
            if(gp[i]==r_gp):
                x[i]+=d+l_x
            if(gp[i]==from_gp):
                gp[i]=to_gp
        if(max(x)>10**9):
            print('No')
            break
else:
    print('Yes')