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, goal):
    q = [[start]]
    q_d = [0]
    d_set = set()
    while(len(q) > 0):
        path = q.pop(0)
        dist = q_d.pop(0)
        w = path[len(path) - 1]
        if w == goal:
            d_set.add(dist)
        else:
            for x in adj_list[w]:
                if x[0] not in path:
                    new_path = path[:]
                    new_path.append(x[0])
                    q.append(new_path)
                    q_d.append(dist + x[1])
    if len(d_set) <= 1:
        return True
    else:
        return False
for i in range(n):
    for j in range(n):
        if not search(i, j):
            print('No')
            exit(0)
print('Yes')
