#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, m;
  long long int ul = 1e9;
  cin >> n >> m;
  if (m == 0) {
    cout << "Yes\n";
    return;
  }
  long long int l[m], r[m], d[m], x[n + 1];
  memset(x, 0, sizeof x);
  bool vis[n];
  memset(vis, 0, sizeof vis);
  for (long long int i = 0; i < m; i++) cin >> l[i] >> r[i] >> d[i];
  bool ok = true;
  for (long long int i = 0; i < m; i++) {
    if (!vis[l[i]] && !vis[r[i]]) {
      vis[l[i]] = 1;
      x[l[i]] = 0;
      vis[r[i]] = 1;
      x[r[i]] = d[i];
    } else if (!vis[r[i]]) {
      vis[r[i]] = 1;
      x[r[i]] = x[l[i]] + d[i];
    } else if (!vis[l[i]]) {
      vis[l[i]] = 1;
      x[l[i]] = x[r[i]] - d[i];
    }
  }
  for (long long int i = 0; i < m; i++) {
    if (x[r[i]] - x[l[i]] != d[i]) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes\n";
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int T = 1;
  while (T--) solve();
  return 0;
}
