// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef long double ld;

#define rep(i, n) for (ll i = 0; i < n; i++)

#define FOR(i, a, b) for (ll i = a; i < b; i++)

#define is(a, b) a == b

#define len(v) ll(v.size())



const ll mod=1e9+7;



//vector書き出し

template <class T>

void cout_vec(const vector<T> &vec1){

  rep(i,len(vec1)){

    cout<<vec1[i]<<' ';

  }

  cout<<'\n';

}



class UnionFind {

public:

	vector<int> par;//親の番号

  vector<int> rank;//木の深さ

  vector<int> size;//各グループの要素数uf.size[uf.find(1)]みたいな感じでfind経由忘れずに

 

	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる

		rep(i,n){

            par.push_back(i);

            rank.push_back(0);

            size.push_back(1);

        }

	}

 

	int find(int x) {//木の根を求める

		if(par[x]==x){

            return x;

        }else{

            return par[x]=find(par[x]);

        }

	}

 

	void unite(int x,int y){//xとyの属する集合を併合

        x=find(x);

        y=find(y);

        if(x==y) return;

        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる

            par[x]=y;

            size[y]+=size[x];

        }else{

            par[y]=x;

            size[x]+=size[y];

            if(rank[x]==rank[y]) rank[x]++;

        }

    }



    bool same(int x,int y){//xとyが同じ集合に属するか否か

        return find(x)==find(y);

    }

};



typedef pair<ll,ll> P;



struct edge{

  ll to,cost;

};



ll n,m;

vector<edge> g[200010];

vector<bool> vis(100010,false);

vector<ll> d(100010,mod);



bool dfs(ll st){

  if(vis[st]||g[st].empty()){

    return true;

  }

  //cout<<' '<<st<<'\n'; 

  vis[st]=true;

  bool flag=true;

  for(auto itr:g[st]){

    if(d[itr.to]!=d[st]+itr.cost && d[itr.to]!=mod){

      flag=false;

    }else{

      d[itr.to]=d[st]+itr.cost;

      //cout<<' '<<d[itr.to]<<'\n';

      if(!dfs(itr.to)){

        flag=false;

      }

    }

  }

  return flag;

}



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

    cin>>n>>m;

    UnionFind uf(n+1);

    ll now;

    rep(i,m){

      ll l,r,d;

      cin>>l>>r>>d;

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

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

      uf.unite(l,r);

      now=l;

    }

    //cout<<now<<'\n';

    d[now]=0;

    ll flag=true;

    if(!dfs(now)){

      flag=false;

    }

    FOR(i,1,n+1){

      if(!uf.same(now,i)){

        now=i;

        d[now]=0;

        if(!dfs(now)){

          flag=false;

        }

      }

    }

    /*

    FOR(i,1,n+1){

      cout<<d[i]<<' '; 

    }

    */

    //cout<<'\n';

    if(flag){

      cout<<"Yes"<<endl;

    }else{

      cout<<"No"<<endl;

    }

}

// Faster C++ solution for the same problem (measured speedup: 1.8684300714248228x):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef long double ld;

#define rep(i, n) for (ll i = 0; i < n; i++)

#define FOR(i, a, b) for (ll i = a; i < b; i++)

#define len(v) ll(v.size())

#define fi first

#define se second



template <class T>

void cout_vec(const vector<T> &vec){

  for(auto itr:vec) cout<<itr<<' ';

  cout<<endl;

}



typedef pair<ll,ll> P;

const ll mod=1e9+7;

const int inf=-1e9;



struct edge{int to,cost;};



int n,m;

vector<vector<edge>> g(100010);

vector<int> d(100010,inf);



bool dfs(int v,int now){

  if(d[v]!=inf){

    if(d[v]!=now) return false;

    else return true;

  }

  d[v]=now;

  bool ret=true;

  for(auto itr:g[v]){

    ret=dfs(itr.to,now+itr.cost);

    if(!ret) break;

  }

  return ret;

}



int main(){

  cin.tie(0);

  ios::sync_with_stdio(false);

  cin>>n>>m;

  rep(i,m){

    int l,r,d;

    cin>>l>>r>>d;

    l--,r--;

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

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

  }

  bool flag=true;

  rep(i,n){

    if(d[i]==inf){

      flag=dfs(i,1e5);

    }

    if(!flag) break;

  }

  if(flag) cout<<"Yes"<<endl;

  else cout<<"No"<<endl;

}