n, m = map(int, input().split())

lrds = [tuple(map(int, input().split())) for _ in range(m)]

xs = [None for _ in range(n)]

ps = [[] for _ in range(n)]

for lrd in lrds:
    l, r, d = lrd
    ps[l-1].append((l-1, r-1, d))
    ps[r-1].append((l-1, r-1, d))

not_decided = set(range(n))

def f(t):
    for lrd in ps[t]:
        l, r, d = lrd
        if l == t:
            another = r
            position = d
        else:
            another = l
            position = -d
        if xs[another] is None:
            xs[another] = xs[t] + position
            not_decided.remove(another)
            f(another)
        else:
            if xs[another] != xs[t] + position:
                return False
    return True

def solve():
    while len(not_decided) != 0:
        t = not_decided.pop()
        xs[t] = 0

        if not f(t):
            return False
    return True

if solve():
    print("Yes")
else:
    print("No")
