#include <bits/stdc++.h>
using namespace std;
typedef struct {
  long l;
  long r;
  long d;
} lrd_t;
int main(void) {
  long n, m;
  cin >> n >> m;
  vector<lrd_t> v(m);
  for (long i = 0; i < m; i++) {
    long l, r, d;
    cin >> l >> r >> d;
    if (l < r) {
      v[i].l = l;
      v[i].r = r;
      v[i].d = d;
    } else {
      v[i].l = r;
      v[i].r = l;
      v[i].d = -d;
    }
  }
  sort(v.begin(), v.end(), [](const lrd_t& a, const lrd_t& b) {
    if (a.l != b.l) {
      return a.l < b.l;
    } else if (a.r != b.r) {
      return a.r < b.r;
    } else {
      return a.d < b.d;
    }
  });
  vector<long> pos(n, 0);
  vector<bool> flag(n, true);
  flag[0] = false;
  for (long i = 0; i < m; i++) {
    if (flag[v[i].r - 1]) {
      pos[v[i].r - 1] = pos[v[i].l - 1] + v[i].d;
      flag[v[i].r - 1] = false;
    } else {
      if (pos[v[i].r - 1] != pos[v[i].l - 1] + v[i].d) {
        cout << "No";
        return 0;
      }
    }
  }
  long max = LONG_MIN;
  long min = LONG_MAX;
  for (long i = 0; i < n; i++) {
    max = pos[i] > max ? pos[i] : max;
    min = pos[i] < min ? pos[i] : min;
  }
  if (max - min <= 1000000000) {
    cout << "Yes";
  } else {
    cout << "No";
  }
  return 0;
}
