#include <cstdio>
#include <iostream>
using namespace std;

const int N = 1e5 + 5;

int fa[N], val[N];

inline int getf(int x) {
  if (x == fa[x]) return x;
  else {
    getf(fa[x]);
    val[x] += val[fa[x]];
    fa[x] = fa[fa[x]];
    return fa[x];
  }
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i ++) fa[i] = i;
  for (int a, b, l, r, d; m; m --) {
    scanf("%d%d%d", &l, &r, &d);
    a = getf(l); b = getf(r);
    if (a == b) {
      if (val[r] - val[l] != d) return puts("No"), 0;
    }
    else {
      d += val[l] - val[r];
      fa[b] = a;
      val[b] += d;
    }
  }
  puts("Yes");
  return 0;
}
