// Original C++ solution (slower):
#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;

    }

}

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

using namespace std;

typedef long long ll;

typedef long double ld;

typedef pair<ll,ll> P;

typedef pair<int,int> Pi;

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

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

#define fi first

#define se second

#define endl "\n"



template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}

template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}

template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}

template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}

template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}

template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}

template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}



const ll mod=1e9+7;

const ll inf=1e17;

const int INF=1e9;

const double PI=acos(-1);

const double EPS=1e-10;



struct edge{int to,cost;};



int main(){

    cin.tie(0);ios::sync_with_stdio(false);

    int n,m;

    cin>>n>>m;

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

    vector<int> l(m),r(m),d(m);

    rep(i,m){

        cin>>l[i]>>r[i]>>d[i];

        l[i]--,r[i]--;

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

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

    }

    vector<int> ans(n,-INF);

    int id=0;

    auto bfs=[&](int v){

        queue<int> que;

        que.push(v);

        ans[v]=0;

        while(!que.empty()){

            int from=que.front();

            que.pop();

            for(auto to:g[from]){

                if(ans[to.to]!=-INF) continue;

                ans[to.to]=ans[from]+to.cost;

                que.push(to.to);

            }

        }

    };

    rep(i,n){

        if(ans[i]==-INF){

            bfs(i);

        }

    }

    rep(i,m){

        if(ans[r[i]]-ans[l[i]]!=d[i]){

            cout<<"No"<<endl;

            return 0;

        }

    }

    cout<<"Yes"<<endl;

}

// Fastest known solution for this problem: