#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
  int n,m;
  cin>>n>>m;
  vector<P> v[111111];
  for(int i=0;i<m;i++){
    int l,r,d;
    cin>>l>>r>>d;
    v[l].push_back(P(r,d));
    v[r].push_back(P(l,-d));
  }
  int cos[111111],ans=1;
  fill(cos,cos+n+1,INT_MAX);
  for(int i=1;i<=n;i++){
    if(cos[i]==INT_MAX){
      queue<P> q;
      q.push(P(i,0));
      while(!q.empty()){
	int to=q.front().first;
	int cost=q.front().second;
	q.pop();
	if(cos[to]==INT_MAX){
	  cos[to]=cost;
	  for(int j=0;j<v[to].size();j++){
	    P p=v[to][j];
	    p.second+=cost;
	    q.push(p);
	  }
	}else if(cos[to]!=cost)ans=0;
      }
    }
  }
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}
