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

l, r, d = [], [], []

for i in range(m):
    l_, r_, d_ = map(int, input().split())
    if l_ < r_:
        l.append(l_-1)
        r.append(r_-1)
        d.append(d_)
    else:
        l.append(r_-1)
        r.append(l_-1)
        d.append(-d_)

import numpy as np
arg = np.argsort(l)

l, r, d = np.array(l)[arg], np.array(r)[arg], np.array(d)[arg]



def solve():
    p = np.array([np.nan for i in range(n)])
    blanches = np.array([-1 for i in range(n)])
    n_blanches = -1

    if m == 0:
        print("Yes")
        return

    for i in range(m):
        if np.isnan(p[l[i]]) and np.isnan(p[r[i]]):
            # create isolate blanch
            n_blanches += 1
            blanches[l[i]] = n_blanches
            blanches[r[i]] = n_blanches
            p[l[i]] = 0
            p[r[i]] = d[i]
        elif np.isnan(p[l[i]]):
            # add rule
            p[l[i]] = p[r[i]] - d[i]
            blanches[l[i]] = blanches[r[i]]

        elif np.isnan(p[r[i]]):
            # add rule
            p[r[i]] = p[l[i]] + d[i]
            blanches[r[i]] = blanches[l[i]]

        else:
            # check merge
            if blanches[r[i]] == blanches[l[i]]:
                # check rule
                if p[r[i]] - p[l[i]] != d[i]:
                    print("No")
                    return
            else:
                # merge
                adj = p[r[i]] - p[l[i]] + d[i]
                p[blanches==blanches[r[i]]] += adj
                blanches[blanches==blanches[r[i]]] = blanches[l[i]]
    print(p)
    print(blanches)
    # check max position
    if np.max(p[~np.isnan(p)]) - np.min(p[~np.isnan(p)]) > 10**9:
        print("No")
    else:
        print("Yes")


solve()