#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;
typedef struct E{
  int to,cost;
}edge;
vector<vector<edge> >E(100010);
int n,m;
bool used[100010]={};
ll human[100010]={};
bool flag=true;
fill(human,100010,-INF);
void dfs(int now,int dis){
  for(int i=0;i<E[now].size();i++){
    if(!used[E[now][i].to]){
      used[E[now][i].to]=true;
      human[E[now][i].to]=dis+E[now][i].cost;
      dfs(E[now][i].to,dis+E[now][i].cost);
    }else{
      if(abs(human[now]-human[E[now][i].to])!=E[now][i].cost)
	flag=false;
    }
  }
}
int main(){
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int l,r,d;cin>>l>>r>>d;
    edge e;
    e.to=r;e.cost=d;
    E[l].pb(e);
    e.to=l;e.cost=-d;
    E[r].pb(e);
  }
  for(int i=1;i<=n;i++){
    if(used[i]==false)
      dfs(i,human[i]);
  }
  if(flag)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}
