class UnionFind:
    def __init__(self, size):
        # 負の値はルート (集合の代表) で集合の個数
        # 正の値は次の要素を表す
        self.table = [-1 for _ in range(size + 1)]

    # 集合の代表を求める
    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            # 経路の圧縮
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    # 併合
    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            if self.table[s1] <= self.table[s2]:
                # 小さいほうが個数が多い
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2
            return True
        return False

def solve(N, M, lrd):
    uf = UnionFind(N + 1)
    for l, r, d in lrd:
        uf.union(l, r)
    xs = {}
    for i in range(1, N + 1):
        n = uf.find(i)
        if not n in xs: xs[n] = {}
        xs[n][i] = None
    for l, r, d in lrd:
        for row in xs.values():
            if l in row:
                break
        if row[l] is None:
            if row[r] is None:
                row[r] = 0
            row[l] = row[r] - d
        else:
            if row[r] is None:
                row[r] = row[l] + d
            else:
                if row[l] != row[r] - d:
                    return False
    for row in xs.values():
        vs = list(row.values())
        if vs[0] is None:
            continue
        #if max(vs) - min(vs) > 10**9:
        #   return False
    return True

if __name__ == "__main__":
    N, M = [int(x) for x in input().split()]
    lrd = []
    for i in range(M):
        lrd.append([int(x) for x in input().split()])
    if solve(N, M, lrd):
        print("Yes")
    else:
        print("No")
