class UnionFindW():
    def __init__(self, n):
        self.tree = [i for i in range(n)]
        self.rank = [0]*n
        self.weight = [0]*n

    def root(self, x):
        if(self.tree[x] == x):
            return x
        self.tree[x] = self.root(self.tree[x])
        self.weight[x] += self.weight[self.tree[x]]
        return self.tree[x]  # 経路圧縮

    def same(self, x, y):  # xとyが同じ木に属するか
        return self.root(x) == self.root(y)

    def unite(self, x, y, w):
        nx = self.root(x)
        ny = self.root(y)
        if self.rank[nx] < self.rank[ny]:  # xの木の高さ>yの木の高さ
            self.tree[nx] = ny
            self.weight[nx] = w-self.weight[x]+self.weight[y]
        else:
            self.tree[ny] = nx
            self.weight[ny] = -w-self.weight[y]+self.weight[x]
            if self.rank[nx] == self.rank[ny]:
                self.rank[nx] += 1

    def diff(self, x, y):
        return self.weight[x] - self.weight[y]


n, m = map(int, input().split())
uf = UnionFindW(n)
inf = []
for _ in range(m):
    l, r, d = map(int, input().split())
    inf.append((l-1, r-1, d))
    uf.unite(l-1, r-1, d)
# print(uf.weight)
for l, r, d in inf:
    if uf.diff(l, r) != d:
        print('No')
        exit(0)
print('Yes')
