class UnionFind:
    def __init__(self, size):
        self.table = [[-1, 0] for _ in range(size + 1)]

    def find(self, x):
        n, d = self.table[x] 
        if n < 0:
            return [x, d]
        else:
            n1, d1 = self.find(n)
            r = [n1, d1 + d]
            self.table[x] = r
            return r

    # 併合
    def union(self, x, y, d):
        n1, d1 = self.find(x)
        n2, d2 = self.find(y)
        if n1 != n2:
            if self.table[n1][0] <= self.table[n2][0]:
                # 小さいほうが個数が多い
                self.table[n2] = [n1, d1+d]
            else:
                self.table[n2][0] -= 1
                self.table[n1] = [n2, d2-d]
        else:
            print(d1, d2, d)
            if d2 - d1 != d:
                return False
        return True

def solve(N, M, lrd):
    uf = UnionFind(N)
    for l, r, d in lrd:
        if not uf.union(l, r, d):
            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")
