#include <cstdio>

const int N = 100000;

int n, m, p[N], d[N];

int find(int u)
{
    if (p[u] == u) {
        return u;
    }
    int r = find(p[u]);
    d[u] += d[p[u]];
    p[u] = r;
    return r;
}

int main()
{
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++ i) {
        p[i] = i, d[i] = 0;
    }
    while (m --) {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        a --;
        b --;
        int pa = find(a);
        int pb = find(b);
        if (pa == pb) {
            if (d[b] - d[a] != c) {
                puts("No");
                return 0;
            }
        } else {
            p[pb] = pa;
            d[pb] = c - d[b] + d[a];
        }
    }
    puts("Yes");
}