#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));
}
int main() {
  int n, m, ll, rr, d;
  scanf("%d%d", &n, &m);
  Init(n);
  bool f = 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 (f) continue;
    int x = cho(ll);
    int y = cho(rr);
    if (x != y) {
      roottree[x] = y;
      ins(ll, rr, d);
    } else {
      x = ser(ll);
      y = ser(rr);
      if (y - x != d) f = 1;
    }
  }
  if (f)
    puts("No");
  else
    puts("Yes");
}
