#include <bits/stdc++.h>
using namespace std;
typedef struct {
  long long st;
  long long fi;
  long long kr;
} rs;
int sortfnc(const void *a, const void *b) {
  if (((rs *)a)->st == ((rs *)b)->st) {
    return 0;
  }
  if (((rs *)a)->st < ((rs *)b)->st) {
    return -1;
  }
  return 1;
}
int main() {
  rs g[524288];
  int n, m, i;
  int l1, r1, d1;
  int l3, r3, d3;
  long long le, ri, di;
  int e[100005];
  long long int f[100005];
  int count = 0;
  queue<int> l, r, d;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    scanf("%lld%lld%lld", &le, &ri, &di);
    g[2 * i].st = le;
    g[2 * i].fi = ri;
    g[2 * i].kr = di;
    g[2 * i + 1].st = ri;
    g[2 * i + 1].fi = le;
    g[2 * i + 1].kr = -di;
  }
  qsort(g, 2 * m, sizeof(rs), sortfnc);
  for (int i = 0; i < 2 * m; i++) {
    l.push(g[i].st);
    r.push(g[i].fi);
    d.push(g[i].kr);
  }
  for (int i = 0; i < n; i++) {
    e[i] = 0;
  }
  if (m == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  count = l.size() - 1;
  while (l.size()) {
    l3 = l.front();
    r3 = r.front();
    d3 = d.front();
    l.pop();
    r.pop();
    d.pop();
    if (e[l3] == 0 && e[r3] == 0) {
      if (count == l.size()) {
        e[l3] = 1;
        e[r3] = 1;
        f[l3] = 0;
        f[r3] = d3;
        count = 0;
      } else {
        count++;
        l.push(l3);
        r.push(r3);
        d.push(d3);
      }
    } else if (e[l3] == 0 && e[r3] == 1) {
      count = 0;
      f[l3] = f[r3] - d3;
      e[l3] = 1;
    } else if (e[l3] == 1 && e[r3] == 0) {
      count = 0;
      f[r3] = f[l3] + d3;
      e[r3] = 1;
    } else {
      count = 0;
      if (f[r3] != (f[l3] + d3)) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}
