N, M = map(int, input().split())
edge = [set() for _ in range(N + 1)]
for _ in range(M):
    l, r, d = map(int, input().split())
    edge[l].add((r, d))
    edge[r].add((l, -d))

visited = set()
for i in range(1, N + 1):
    dist = {}
    dfs_stack = []
    if i not in visited:
        visited.add(i)
        dist[i] = 0
        dfs_stack.append(i)
    while dfs_stack:
        s = dfs_stack.pop()
        for t, d in edge[s]:
            if t in dist:
                if dist[t] != dist[s] + d:
                    print('No')
                    exit()
            else:
                dist[t] = dist[s] + d
            if t not in visited:
                visited.add(t)
                dfs_stack.append(t)

    if len(set(dist.keys())) != len(set(dist.values())):
        print('No')
        exit()

print('Yes')