#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;

int par[100010];
int rank[100010];
int weight[100010];

void init(int n){
  for(int i=0;i<n;i++){
    par[i]=i;rank[i]=0;weight[i]=0;
  }
  return;
}

int root(int n){
  if(par[n]==n){
    return n;
  }
  int r=root(par[n]);
  weight[n]+=weight[par[n]];
  return par[n]=r;
}

void unite(int x,int y,int w){
  int rx=root(x),ry=root(y);
  if(rx==ry){
    return;
  }
  if(rank[x]<rank[y]){
    par[rx]=ry;
    weight[rx]=w-weight[x]+weight[y];
  }  
  else{
    par[ry]=rx;
    weight[ry]=-w+weight[x]-weight[y];
    if(rank[rx]==rank[ry]) rank[rx]++;
  }
}

bool same(int x,int y){
  return root(x)==root(y);
}

int diff(int x,int y){
  return weight[x]-weight[y];
}

int main() {
  int n,m;
  cin>>n>>m;
  init(n);
  for(int i=0;i<m;i++){
    int l,r,d;
    cin>>l>>r>>d;
    if(same(l-1,r-1)){
      if(d==diff(r,l)) continue;
      else {
        cout<<"No"<<endl;
        return 0;
      }
    }
    else unite(l,r,d);
  }
  cout<<"Yes"<<endl;
  return 0;
}
