#include <bits/stdc++.h>
using namespace std;
int val[111111];
int l[111111];
int r[111111];
int f[111111];
int roottree[111111];
map<int, int> c;
int cho(int x) { return roottree[x] == x ? x : roottree[x] = cho(roottree[x]); }
void ins(int le, int re, int key) {
  if (key >= 0) {
    if (r[le] != -1) {
      ins(r[le], re, key - val[r[le]]);
    } else {
      r[le] = re;
      val[re] = key;
      f[re] = le;
    }
  } else {
    if (l[le] != -1) {
      ins(l[le], re, key - val[l[le]]);
    } else {
      l[le] = re;
      val[re] = key;
      f[re] = le;
    }
  }
}
int ser(int l) {
  int v = 0;
  while (f[l] != -1) {
    v += val[l];
    l = f[l];
  }
  return v;
}
void Init(int n) {
  for (int i = 0; i <= n; ++i) roottree[i] = i;
  memset(f, -1, sizeof(f));
  memset(l, -1, sizeof(l));
  memset(r, -1, sizeof(r));
  memset(val, 0, sizeof(val));
}
int main() {
  int n, m, ll, rr, d;
  while (~scanf("%d%d", &n, &m)) {
    c.clear();
    Init(n);
    bool fl = 0;
    int g = 0;
    while (m--) {
      scanf("%d%d%d", &ll, &rr, &d);
      if (!c[ll]) c[ll] = ++g;
      if (!c[rr]) c[rr] = ++g;
      ll = c[ll];
      rr = c[rr];
      if (fl) continue;
      int x = cho(ll);
      int y = cho(rr);
      if (x != y) {
        roottree[x] = y;
        d = d - ser(rr) + ser(ll);
        while (f[rr] != -1) rr = f[rr];
        while (f[ll] != -1) ll = f[ll];
        ins(ll, rr, d);
      } else {
        x = ser(ll);
        y = ser(rr);
        if (y - x != d) fl = 1;
      }
    }
    if (fl)
      puts("No");
    else
      puts("Yes");
  }
}
