N, M = map(int, input().split())
Edge = [[] for i in range(N)]
for i in range(M):
    l, r, d = map(int, input().split())
    Edge[l-1].append((r-1, d))
    Edge[r-1].append((l-1, -d))
Left = [int(i) for i in range(N)]
Visit = [False for i in range(N)]
Node = [0 for i in range(N)]
Possible = True

while Left and Possible:
    start = Left.pop(0)
    Visit[start] = True
    Q = [start]
    while Q:
        now = Q.pop(0)
        for e in Edge[now]:
            if Visit[e[0]] == False:
                Visit[e[0]] = True
                Left.remove(e[0])
                Node[e[0]] = Node[now] + e[1]
                Q.append(e[0])
            elif e[0] != now:
                dest = Node[now] + e[1]
                if dest != Node[e[0]]:
                    Possible = False
                    break
print("Yes" if Possible else "No")
