#include <cstdio>
#include <algorithm>

const int MAXN = 100004;

int N;
int uf[MAXN];
long long xx[MAXN];

int findp(int);

int main() {
  int N, q;
  scanf("%d%d", &N, &q);
  std::fill(uf, uf + N, -1);
  for (int i = 0; i < q; ++i) {
    int l, r, d;
    scanf("%d%d%d", &l, &r, &d);

    int ll = findp(l), rr = findp(r);
    if (ll == rr) {
      if (xx[r] - xx[l] != d) goto fail;
      continue;
    }

    uf[rr] = ll;
    xx[rr] = (d + (long long)xx[l]) - xx[r];
  }
  puts("Yes");
  return 0;

fail:
  puts("No");
  return 0;
}

int Q[MAXN];
int qr;

int findp(int t) {
  Q[0] = t;
  qr = 1;
  int pt = uf[t];
  while (pt != -1) {
    t = Q[qr++] = pt;
    pt = uf[t];
  }
  int sum = 0;
  for (int i = qr - 2; i >= 0; --i) {
    sum += xx[Q[i]];
    xx[Q[i]] = sum;
    uf[Q[i]] = t;
  }
  return t;
}
