import sys

n,m = map(int, input().split())
adj_list = [[] for i in range(n)]
for i in range(m):
    l, r, d = map(int, input().split())
    adj_list[l-1].append((r-1, d))
    adj_list[r-1].append((l-1, -d))
def search(start):
    q = [[start]]
    q_d = [0]
    q_d = [0]
    dist_all = [None for i in range(n)]
    while(len(q) > 0):
        path = q.pop(0)
        dist = q_d.pop(0)
        w = path[len(path) - 1]
        for x in adj_list[w]:
            if x[0] not in path:
                new_path = path[:]
                new_path.append(x[0])
                if dist_all[x[0]] is None:
                    dist_all[x[0]] = dist + x[1]
                elif dist_all[x[0]] != dist + x[1]:
                    return False
                q.append(new_path)
                q_d.append(dist + x[1])
    return True
for i in range(n):
    if not search(i):
        print('No')
        exit(0)
print('Yes')
