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]
        x=[x_+d+gp[l-1] if gp[i]==gp[r-1] else x_ for i,x_ in enumerate(x)]
        gp=[to_gp if gp_==from_gp else gp_ for gp_ in gp]
        if(max(x)>100000):
            print('No')
            break
else:
    print('Yes')