#include <bits/stdc++.h>
#define il inline
#define RG register
#define ll long long
#define N (500005)

using namespace std;

struct edge{ int nt,to,dis; }g[N];

int head[N],dis[N],vis[N],n,m,num;

il int gi(){
  RG int x=0,q=1; RG char ch=getchar();
  while ((ch<'0' || ch>'9') && ch!='-') ch=getchar();
  if (ch=='-') q=-1,ch=getchar();
  while (ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
  return q*x;
}

il void insert(RG int from,RG int to,RG int dis){
  g[++num]=(edge){head[from],to,dis},head[from]=num; return;
}

il void dfs(RG int x){
  vis[x]=1;
  for (RG int i=head[x],v;i;i=g[i].nt){
    v=g[i].to;
    if (!vis[v]) dis[v]=dis[x]+g[i].dis,dfs(v);
    else if (dis[v]!=dis[x]+g[i].dis) puts("No"),exit(0);
  }
  return;
}

int main(){
  n=gi(),m=gi();
  for (RG int i=1,l,r,d;i<=m;++i){
    l=gi(),r=gi(),d=gi(); if (l>r) swap(l,r);
    insert(l,r,d),insert(r,l,-d);
  }
  for (RG int i=1;i<=n;++i) if (!vis[i]) dfs(i);
  puts("Yes"); return 0;
}
