#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std; typedef long long ll; const ll INF=1e18;
typedef pair<int,int> P;

int main() {
  int n,m; cin>>n>>m;
  ll l[m], r[m], d[m];
  for(int i=0;i<m;i++) cin>>l[i]>>r[i]>>d[i];
  for(int i=0;i<m;i++) l[i]--,r[i]--;

  bool able[m]={};
  vector<int> c[n];
  for(int i=0;i<m;i++) {
    c[l[i]].push_back(i);
    c[r[i]].push_back(i);
  }
  queue<int> que; ll p[n]; fill(p,p+n,INF);

  bool collapsed=false;

  for(int i=0;i<m;i++) {
    if (able[i]) continue;
    able[i]=true; que.push(i); p[l[i]]=0;

    while(!que.empty()) {
      int id = que.front(); que.pop();
      if (p[l[id]]==INF) p[l[id]]=p[r[id]]-d[id];
      else if (p[r[id]]==INF) p[r[id]]=p[l[id]]+d[id];
      else {
        if (p[l[id]] + d[id] != p[r[id]]) collapsed = true;
      }
      for(int x:c[id]) {
        if (!able[x]) able[x]=true, que.push(x);
      }
      c[id].clear();
    }
  }

  //for(int i=0;i<n;i++) cout<<p[i]<<endl;

  if (collapsed) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}