#include<bits/stdc++.h>
using namespace std;

int n,m,fa[202000],d[202000];

int GF(int x){
  if (fa[fa[x]]==fa[x]) return fa[x];
  int orgfa=fa[x];
  fa[x]=GF(fa[x]);
  d[x]+=d[orgfa];
  return fa[x];
}
int dis(int x){
  return fa[x]==x? 0: d[x]+dis(fa[x]);
}

void onion(int x,int y,int v){
  int fx=GF(x), dx=dis(x), fy=GF(y), dy=dis(y), las;
  las=-dx+dy+v;
  if (fx==fy){
    if (las){
      puts("No");
      exit(0);
    }
  }else{
    fa[fx]=fy;
    d[fx]=las;
  }
}

int main(){
  cin>>n>>m;
  for (int i=1;i<=n;++i)
    fa[i]=i, d[i]=0;
  int l,r,x;
  for (;m--;){
    scanf("%d%d%d",&l,&r,&x);
    onion(r,l,x);
  }
  puts("Yes");
}
