n, m = map(int,input().split())

a = [[] for _ in range(n+1)]

for _ in range(m):
    l, r, d = map(int,input().split())
    a[l].append((r,d))
    a[r].append((l,-d))

x = [float('inf') for _ in range(n+1)]

flag = [True]



def check(start,destination,cost):
    #x[destination] = x[start] + cost
    if x[destination] == float('inf'):
        x[destination] = x[start] + cost
        while a[destination]:
            n_destination, n_cost = a[destination].pop()
            check(destination,n_destination,n_cost)
    else:
        if x[destination] == x[start] + cost:
            while a[destination]:
                n_destination, n_cost = a[destination].pop()
                check(destination,n_destination,n_cost)
        else:
            flag[0] = False

for i in range(1,n+1):
    if a[i]:
        x[i] = 0
        for y in a[i]:
            check(i,y[0],y[1])
    else:
        pass

if flag[0]:
    print('Yes')
else:
    print('No')