#include <cstdlib>
#include <cstdio>
#include <algorithm>
#define maxn 100005
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
using namespace std;

int ufs[maxn];
int val[maxn];
int get(int x){
    int t = (x == ufs[x]) ? x : get(ufs[x]);
    val[x] += val[ufs[x]];
    return ufs[x] = t;
}

int main(){
    int n, m;
    int x, y, d;
    scanf("%d%d", &n, &m);
    rep(i, 1, n) ufs[i] = i;
    rep(i, 1, m){
        scanf("%d%d%d", &x, &y, &d);
        int _x = get(x), _y = get(y);
        if (_x == _y) {
            if (val[x] - val[y] != d) {
                printf("No");
                return 0;
            }
        }
        else val[_x] = d + val[y] - val[x], ufs[_x] = _y;  
    }
    printf("Yes");
    return 0;
}