#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

ll H[100010];
ll dist[100010][100010];

bool func(pair<pair<ll,ll>,ll> a, pair<pair<ll,ll>,ll>b){
  if(a.first.first != b.first.first) return a.first.first < b.first.first;
  else return a.first.second < b.first.second;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N,M;
  cin >> N >> M;
  vector<pair<pair<ll,ll>, ll> > inf;

  rep(i,M){
    ll l,r,d; cin >> l >> r >> d;
    if(r<l){
      swap(l,r);
      d = -d;
    }
    inf.pb(mp(mp(l,r),d));
  }

  sort(all(inf),func);

  /*
  HEAD[1] = 0;
  dist[0][1] = 0;
  */
  rep(i,M){
    ll L = inf[i].first.first;
    ll R = inf[i].first.second;
    ll D = inf[i].second;

    H[R] = H[L];
    dist[H[R]][R] = dist[H[L]][L]+D;
  }

  rep(i,M){
    ll L = inf[i].first.first;
    ll R = inf[i].first.second;
    ll D = inf[i].second;
    if(dist[H[R]][R] - dist[H[L]][L] != D) {cout <<"No" << endl; return 0;}
    
  }
  
  cout <<"Yes" << endl;
  
  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}
