#pragma GCC optimize ("O3,Ofast,inline,fast-math,unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
const double EPS=1e-7;
const int MOD=1e9+7;
#define int int64_t
#define double long double
// typedef
#define vdef(t,T) typedef vector<t> V##T;typedef vector<V##T> VV##T;typedef vector<VV##T> VVV##T;
#define pdef(t1,t2,T) typedef pair<t1,t2> P##T;vdef(P##T,P##T)
vdef(int,I)vdef(double,D)vdef(char,C)vdef(string,S)pdef(int,int,II)pdef(int,PII,III)
pdef(string,PII,SII)
// template
#define TCC template<class C>
#define TCC12 template<class C1,class C2>
#define TCC12C template<class C1,class C2,class CC>
#define TCCC template<class C,class CC>
#define VCL vector<C>
#define VVCL vector<VCL>
#define PCC pair<C1,C2>
// define use frequently
#define emb emplace_back
#define pub push_back
#define pob pop_back
#define mp make_pair
#define mp3(a,b,c) mp(a,mp(b,c))
#define fi first
#define se second
#define fir fi
#define sec se.fi
#define thi se.se
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(n) fou(_,0,n)
#define tra(a,x) for(auto& a : x)
#define elif(c) else if(c)
#define si(vec) ((int)(vec).size())
#define all(vec) vec.begin(),vec.end()
#define lla(vec) vec.rbegin(),vec.rend()
#define range(vec,x,y) vec.begin()+x,vec.begin()+y
#define sortup(vec) sort(all(vec))
#define sortdown(vec) sort(lla(vec))
#define eraseif(vec,condition_VAR) vec.erase(remove_if(all(vec),[&](auto VAR){return condition_VAR;}),vec.end())
#define erase_unique(vec) vec.erase(unique(all(vec)),vec.end())
TCC void rotateleft(VCL&vec,const int&n){rotate(vec.begin(),vec.begin()+n,vec.end());}
TCC void rotateright(VCL&vec,const int&n){rotate(vec.rbegin(),vec.rbegin()+n,vec.rend());}
TCC int mine(VCL&vec){int s=si(vec);C m=0;fou(i,1,s)if(vec[i]<vec[m])m=i;return m;}
TCC int maxe(VCL&vec){int s=si(vec);C m=0;fou(i,1,s)if(vec[i]>vec[m])m=i;return m;}
TCC void mini(C&a,const C&b){a=min(a,b);}
TCC void maxi(C&a,const C&b){a=max(a,b);}
// make_pair,vector calculate
#define opall(calc) calc(+)calc(-)calc(*)calc(/)calc(%)calc(<<)calc(>>)calc(&)calc(|)calc(^)
#define p1c(op) TCC12C PCC operator op(const PCC&l,const CC&r){return mp(l.fi op r,l.se op r);}
#define p2c(op) TCC12 PCC operator op(const PCC l,const PCC&r){return mp(l.fi op r.fi,l.se op r.se);}
#define v1c(op) TCCC VCL operator op(VCL l,const CC&r){tra(le,l)le=le op r;return l;}
#define v2c(op) TCC VCL operator op(VCL l,const VCL&r){int s=min(si(l),si(r));fou(i,0,s)l[i]=l[i] op r[i];return l;}
#define opeq(op) TCC12 C1 operator op##=(C1&l,const C2&r){return l=l op r;}
opall(p1c)opall(p2c)opall(v1c)opall(v2c)opall(opeq)
// iostream
#define in(T,...) T __VA_ARGS__;_in(__VA_ARGS__)
void _in(){}template<class Head,class...Tail>void _in(Head&head,Tail&&...tail){cin>>head;_in(forward<Tail>(tail)...);}
template<class Head>void out(const Head&head){cout<<head<<endl;}template<class Head,class...Tail>void out(const Head&head,Tail...tail){cout<<head<<" ";out(forward<Tail>(tail)...);}TCC void vout(const VCL&vec){tra(v,vec)out(v);}
TCC12 istream&operator>>(istream&is,PCC&p){return is>>p.fi>>p.se;}TCC istream&operator>>(istream&is,VCL&vec){tra(v,vec)is>>v;return is;}TCC12 ostream&operator<<(ostream&os,const PCC&p){os<<p.fi<<" "<<p.se;return os;}TCC ostream&operator<<(ostream&os,const VCL&vec){int vecsize=si(vec);fou(i,0,vecsize-1)os<<vec[i]<<" ";os<<vec[vecsize-1];return os;}
// math
TCC C sign(C a){return (a>0)-(a<0);}
int gcds(const int&a,const int&b){return b?gcds(b,a%b):a;}int gcd(const int&a,const int&b){return gcds(max(a,b),min(a,b));}
int lcm(const int&a,const int&b){return a/gcd(a,b)*b;}
int fact(const int&n,const int&prod){return (n==0)?prod:fact(n-1,n*prod);}int fact(const int&n){return fact(n,1);}
PII comb(const int&m,const int&n,const PII&nd){return (n==0)?nd:comb(m-1,n-1,mp(m,n)*nd);}int comb(const int&m,const int&n){PII p=comb(m,min(n,m-n),mp((int)1,(int)1));return p.fi/p.se;}
int modnum(const int&a){return a%MOD+(a<0?MOD:0);}
int modinv(int a){a=modnum(a);int b=MOD,u=0,v=1;while(a>1){u-=b/a*v;b%=a;swap(a,b);swap(u,v);}return modnum(v);}
#define modcalc(opstr,op) int mod##opstr(const int&a,const int&b){return modnum(modnum(a) op modnum(b));}
modcalc(add,+)modcalc(sub,-)modcalc(mul,*)
int moddiv(const int&a,const int&b){return modmul(a,modinv(b));}
int modpow(int a,int b){int r=1;while(b>0){if(b&1)r=modmul(r,a);a=modmul(a,a);b>>=1;}return r;}
// vector,matrix
TCC C vecsum(const VCL&vec,const int&l,const int&r){C sum=0;fou(i,l,r)sum+=vec[i];return sum;}
TCC C dot(const VCL&vec1,const VCL&vec2){int s=min(si(vec1),si(vec2));int sum=0;fou(i,0,s)sum+=vec1[i]*vec2[i];return sum;}TCC VVCL dot(const VVCL&mat1,const VVCL&mat2){int h=si(mat1),w=si(mat2[0]);VVCL mat(h,VI(w));int s=min(si(mat1[0]),si(mat2));fou(i,0,h)fou(j,0,w)fou(k,0,s)mat[i][j]+=mat1[i][k]*mat2[k][j];return mat;}
// cumulated sum
TCC void cumsum(VCL&vec){int s=si(vec);fou(i,1,s)vec[i]+=vec[i-1];}TCC void cumsum(VVCL&vec){int s=si(vec);fou(i,1,s)vec[i]+=vec[i-1];fou(i,0,s)cumsum(vec[i]);}
TCC C partsum(VCL&vec,const int&l,const int&r){return (l==0)?vec[r-1]:vec[r-1]-vec[l-1];}TCC C partsum(VVCL&vec,const int&l1,const int&r1,const int&l2,const int&r2){return (vec[r1-1][r2-1])-((l1==0)?0:vec[l1-1][r2-1])-((l2==0)?0:vec[r1-1][l2-1])+((l1==0||l2==0)?0:vec[l1-1][l2-1]);}
// algorithm
TCC class BIT{VCL tree;int n;public:BIT(int _n):n(_n){tree.resize(n);}void add(int x,C v){while(x<n){tree[x]+=v;x|=(x+1);}}C sum(int x){C v=0;while(x>=0){v+=tree[x];x=(x&(x+1))-1;}return v;}C part(int x,int y){return sum(y-1)-sum(x-1);}C get(int x){return part(x,x+1);}void set(int x,int y){add(x,-get(x)+y);}};
TCC class unionfind{VI par;VCL wei;int n;public:
unionfind(int _n):n(_n){par.resize(n);iota(all(par),1);wei.resize(n);}
int get(const int&x){if(par[x]==(x+1))return x+1;else{
  int parent=sign(par[x])*get(abs(par[x])-1);
  wei[x]+=wei[abs(par[x])-1];
  return par[x]=parent;
}}
void get(int&x,int&y){x=get(x);y=get(y);}
int weight(int x){get(x);return wei[x];}
void unite(int x,int y,C w){w+=weight(x)-weight(y);get(x,y);if(abs(x)!=abs(y)){par[abs(y)-1]=x*sign(y);wei[abs(y)-1]=w;}}
void separate(int x,int y,C w){w+=weight(x)-weight(y);get(x,y);if(abs(x)!=abs(y)){par[abs(y)-1]=-x*sign(y);wei[abs(y)-1]=w;}}
int same(int x,int y){get(x,y);return (x==y)-(x==-y);}
C diff(int x,int y){return weight(y)-weight(x);}};

TCC int binarysearch(const VCL&vec,const C&n,const char&c){
  int left=-1;int right=si(vec);bool outleft=(c=='d'||c=='U');int getmin=(c=='u'||c=='d')?1:-1;
  while(right-left>1){
    int mid=left+(right-left)/2;
    bool OK=vec[mid]*getmin>=n*getmin;
    if(outleft==OK) left=mid;else right=mid;
  }
  return outleft?left:right;
}








signed main(){IOS;
  // unionfind<int> uf(10);
  // uf.unite(2,3,3);
  // uf.unite(1,2,2);
  // uf.unite(0,1,2);
  // fou(i,0,10) out(uf.get(i),uf.weight(i));


  in(int,n,m);
  unionfind<int> uf(n);

  string ans="Yes";
  fou(i,0,m){
    in(int,l,r,d);
    l--;r--;
    if(!uf.same(l,r)){
      uf.unite(l,r,d);
    }else{
      if(uf.diff(l,r)!=d){
        ans="No";
        break;
      }
    }
  }
  out(ans);
}

Measured memory_bytes: 1792