from collections import deque
import sys


class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def roots(self):
        return {i for i, x in enumerate(self.parents) if x < 0}


n, m = map(int, input().split())
graph = []
uf = UnionFind(n+1)
for _ in range(m):
    l, r, d = map(int, input().split())
    uf.union(l, r)
    graph.append((l, r, d))

x = {}
re_check = deque([])
# 根の座標を０で確定
for i, y in enumerate(uf.parents):
    if y < 0:
        x[i] = 0

for l, r, d in graph:
    if l in x.keys() and r in x.keys():
        if x[r] - x[l] != d:
            print("No")
            sys.exit()
    elif l in x.keys():
        x[r] = x[l] + d
    elif r in x.keys():
        x[l] = x[r] - d
    else:
        re_check.append((l, r, d))

while re_check:
    l, r, d = re_check.popleft()
    if l in x.keys() and r in x.keys():
        if x[r] - x[l] != d:
            print("No")
            sys.exit()
    if l in x.keys():
        x[r] = x[l] + d
    elif r in x.keys():
        x[l] = x[r] - d
    else:
        re_check.append((l, r, d))

if max(x.values()) - min(x.values()) > 10**9:
    print("No")
else:
    print("Yes")
