// Original C++ solution (slower):




#include<stdio.h>

#include<string.h>

#include<stdlib.h>

#include<math.h>

#include<stack>

#include<queue>

#include<vector>

#include<algorithm>

#include<string>

#include<iostream>

#include<set>

#include<map>



using namespace std;

typedef long long ll;

#define i_7 1000000007

#define i_5 1000000005



ll mod(ll a){

    ll c=a%i_7;

    if(c>=0)return c;

    else return c+i_7;

}

typedef pair<int,int> i_i;

typedef pair<ll,ll> l_l;

#define inf 100000000/*10^8*/



/////////////////////////////////



#define nil 1000000005



#define N 100002

struct edge{

    int to,dis;

};

int n,m;

vector<edge>e[N];

int used[N];







int main(){

    cin>>n>>m;

    for(int i=0;i<m;i++){

        int l,r,d;cin>>l>>r>>d;

        e[l].push_back(edge{r,d});

        e[r].push_back(edge{l,-d});

    }

   

    

    for(int i=1;i<=n;i++){

        used[i]=nil;

    }

    int checked=1;

    while(checked<=n){

        queue<int>q;

        q.push(checked);

        used[checked]=0;

        while(!q.empty()){

            int sta=q.front();q.pop();

            for(auto x:e[sta]){

                if(used[x.to]==nil){

                used[x.to]=x.dis+used[sta];

                q.push(x.to);

                }else{

                    if(used[x.to]!=x.dis+used[sta]){

                        cout<<"No"<<endl;

                        return 0;

                    }

                }

            }

        }

        while(used[checked]!=nil&&checked<=n)checked++;

    }

    cout<<"Yes"<<endl;

    

    

    return 0;

}


// Optimized solution to the same problem (faster):
//#include <bits/stdc++.h>

#include "bits/stdc++.h"



using namespace std;

typedef long long ll;

//#include <boost/multiprecision/cpp_int.hpp>

//typedef boost::multiprecision::cpp_int ll;

typedef long double dd;



#define i_7 (ll)(1E9+7)

//#define i_7 998244353

#define i_5 i_7-2

ll mod(ll a){

    ll c=a%i_7;

    if(c>=0)return c;

    return c+i_7;

}

 

typedef pair<ll,ll> l_l;

ll inf=(ll)1E16;

#define rep(i,l,r) for(ll i=l;i<=r;i++)

#define pb push_back

ll max(ll a,ll b){if(a<b)return b;else return a;}

ll min(ll a,ll b){if(a>b)return b;else return a;}



void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);

void Min(ll &pos,ll val){pos=min(pos,val);}

void Add(ll &pos,ll val){pos=mod(pos+val);}

dd EPS=1E-9;

#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define fi first

#define se second

////////////////////////////







int main(){fastio

    ll n,m;cin>>n>>m;

    vector<l_l>v[n+1];

    rep(i,1,m){

        ll a,b,c;cin>>a>>b>>c;

        v[a].pb(l_l(b,c));

        v[b].pb(l_l(a,-c));

    }

    ll d[n+1];rep(i,1,n)d[i]=inf;

    rep(i,1,n){

        if(d[i]==inf){

            d[i]=0;

            queue<ll>q;q.push(i);

            while(!q.empty()){

                ll t=q.front();q.pop();

                for(auto y:v[t]){

                    ll to=y.fi,dis=y.se;

                    if(d[to]==inf){

                        d[to]=d[t]+dis;

                        q.push(to);

                    }else{

                        if(d[to]!=d[t]+dis){

                            cout<<"No"<<endl;return 0;

                        }

                    }

                }

            }

        }

    }

    cout<<"Yes"<<endl;

    return 0;

}


// Fastest known solution for this problem: