#include <bits/stdc++.h>
#include <vector>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
 
struct kank{
  ll num;
  ll dx;
};
 
int main(){
  
  ll n,m;
  cin>>n>>m;
  ll l[m],r[m],d[m];
  list<kank> kanks[n+1];
  REP(i,m){
    cin>>l[i]>>r[i]>>d[i];
    kank k;
    k.num = r[i];
    k.dx = d[i];
    kanks[l[i]].push_back(k);
    k.num = l[i];
    k.dx = -d[i];
    kanks[r[i]].push_back(k);
  }
  
  string ans = "Yes";
  ll x[n+1];
  REP(i,n+1){
    x[i] = 0;
  }
  bool tukatta[n+1];
  REP(i,n+1){
    tukatta[i] = false;
  }
  
  for(int i=1;i<=n;i++){
    if(tukatta[i]==false){
      tukatta[i] = true;
      queue<ll> q;
      q.push(i);
      while(q.size()){
        ll l = q.front();
        q.pop();
        tukatta[l] = true;
        while(kanks[l].size()){
          kank k = kanks[l].front();
          kanks[l].pop_front();
          if(tukatta[k.num]){
            if((x[k.num]-x[l])!=k.dx){
//              cout<<k.dx<<" "<<x[k.num]-x[l]<<endl;
              ans="No";
              cout<<ans<<endl;
              return 0;
            }
          }else{
 
            x[k.num] = x[l] + k.dx;
        //                cout<<k.num<<" "<<x[k.num]<<endl;
            q.push_back(k.num);
            tukatta[k.num]=true;
          }
        }
      }
    }
  }
  cout<<ans<<endl;
  
  return 0;
}