#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n,m;cin>>n>>m;
  bool flag=true;
  ll human[n+10]={};
  priority_queue<pair<pair<int,int>,int >,vector<pair<pair<int,int>,int> >,greater<pair<pair<int,int>,int > > >que;
  for(int i=0;i<m;i++){
    int l,r,d;cin>>l>>r>>d;

    if(l<r){
      que.push(mp(mp(l,r),d));
    }else{
      que.push(mp(mp(r,l),d));
    }
  }
  while(!que.empty()){
    pair<pair<int,int>,int> p=que.top();que.pop();
    if(human[p.F.S]==0)human[p.F.S]=p.S;
    else{
      if(human[p.F.F]+p.S!=human[p.F.S])
	flag=false;
    }
  }
  if(flag)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}
