#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

int diff(int x,int y){//w[y]-w[x],比較不可なら-1
    if(!same(x,y)) return -1;
    return wei(y)-wei(x);
}


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,m,l,r,d;
    cin>>n>>m;
    init(n);
    rep(i,m){
        cin>>l>>r>>d;
        r --;
        l --;
        if(diff(l,r)==d) continue;
        else if(same(l,r)){
            cout<<"No"<<endl;
            return 0;
        }
        else unite(l,r,d);
    }
    cout<<"Yes"<<endl;
}