#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<int> par(n), nxt(n, -1), x(n, 0), s(n, 1);
  for (int i = 0; i < (n); ++i) par[i] = i;
  bool good = true;
  for (int i = 0; i < (m); ++i) {
    int l, r, d;
    cin >> l >> r >> d;
    --l, --r;
    if (par[l] == par[r]) {
      if (x[r] - x[l] != d) {
        good = false;
        break;
      }
    } else {
      if (s[par[l]] > s[par[r]]) {
        swap(l, r);
        d = -d;
      }
      l = par[l], r = par[r];
      int last = l;
      for (int j = l; j != -1; j = nxt[j]) {
        par[j] = r;
        x[j] -= d;
        last = j;
      }
      s[r] += s[l];
      nxt[last] = nxt[r];
      nxt[r] = l;
    }
  }
  if (good)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
