n, m = map(int, input().split())
lrd = [list(map(int, input().split())) for _ in range(m)]


class UnionFind:
    def __init__(self, x):
        self.p = [e for e in range(x)]
        self.rank = [0] * x
        self.d = [0] * x

    def same(self, u, v):
        return self.find_set(u) == self.find_set(v), self.d[u] + self.d[v]

    def unite(self, u, v, dist):
        self.link(self.find_set(u), self.find_set(v), dist)

    def find_set(self, u):
        if u != self.p[u]:
            d, self.p[u] = self.find_set(self.p[u])
            self.d[u] += d

        return self.d[u], self.p[u]

    def link(self, fsu, fsv, dist):
        du, u = fsu
        dv, v = fsv
        if self.rank[u] > self.rank[v]:
            self.p[v] = u
            self.d[v] = self.d[u] + dist
        else:
            self.p[u] = v
            if self.rank[u] == self.rank[v]:
                self.rank[v] += 1
            self.d[u] = self.d[v] + dist


uf = UnionFind(n)

for l, r, d in lrd:
    l -= 1
    r -= 1

    bl, dist = uf.same(l, r)

    if bl:
        if d != dist:
            print("No")
            exit()

    else:
        uf.unite(l, r, d)

d_mn = 0
d_mx = 0
for i in range(n):
    d = uf.d[i]
    d_mn = min(d_mn, d)
    d_mx = max(d_mx, d)

if d_mx - d_mn > 10 ** 9:
    ans = "No"
else:
    ans = "Yes"

print(ans)
