#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

ll mod = 1e9 + 7;

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

  ll n, m;
  cin >> n >> m;

  ll l[m], r[m], d[m], x[n + 1] = {}, vst[n + 1] = {};
  REP(i, m) cin >> l[i] >> r[i] >> d[i];

  REP(i, m){
    if(vst[r[i]] && x[r[i]] - x[l[i]] != d[i]){
      cout << "No" << endl;
      return 0;
    }
    else x[r[i]] = x[l[i]] + d[i];
    vst[l[i]]++;
    vst[r[i]]++;
  }
  SORT(x, n);
  if(x[n - 1] > 1e9){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}
