import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

/// Number of k-combinations
T combination(T = long)(T n, T k)
{
    assert(0 <= k);
    assert(0 <= n);
    if (n < k)
        return 0;
    k = min(n - k, k);
    if (k == 0)
        return 1;
    if (k == 1)
        return n;
    return memoize!combination(n - 1, k - 1) + memoize!combination(n - 1, k);
}

void main()
{
    long N, M;
    scan(N, M);
    auto dist = new long[](N);
    auto roots = iota(N).array();
    long root(long x)
    {
        if (roots[x] == x)
            return x;
        long parent = roots[x];
        roots[x] = root(parent);
        dist[x] += dist[parent];
        return roots[x];
    }

    foreach (_; 0 .. M)
    {
        long L, R, D;
        scan(L, R, D);
        L--;
        R--;
        long rL = root(L);
        long rR = root(R);
        if (rL != rR)
        {
            roots[rR] = rL;
            dist[rR] = dist[rL] + D + (dist[L] - dist[R]);
        }
        else if (dist[L] + D != dist[R])
        {
            writeln("No");
            return;
        }
    }
    // writeln(dist);
    writeln("Yes");
}
