#include <bits/stdc++.h>

using namespace std;
const int maxn = 100010;
int pa[maxn], d[maxn];
int n, m;

int findset(int x)
{
    if(pa[x] == x)return x;
    int t = findset(pa[x]);
    d[x] += d[pa[x]];
    pa[x] = t;
    return pa[x];
}

int main()
{
    memset(d, 0, sizeof(d));
    scanf("%d%d", &n, &m);
    for(int i = 0; i <= n; i++)
        pa[i] = i;
    for(int i = 1; i <= m; i++) {
        int x, y, w;
        scanf("%d%d%d", &x, &y, &w);
        int p = findset(x), q = findset(y);
        if(p != q) {
            pa[p] = q;
            d[p] = d[y] - (d[x] + w);
        } else if(d[y] - d[x] != w) {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}
