#include <bits/stdc++.h>
using namespace std;
int f[223456], d[223456], a[223456];
void UFSinit(int x) {
  while (x-- > 0) f[x] = x;
}
int UFSfind(int x) {
  if (f[x] != x) d[x] += d[f[x]], f[x] = UFSfind(f[x]);
  return f[x];
}
int UFSmerge(int x, int y, int z) {
  int fa = UFSfind(x);
  f[fa] = y;
  return d[fa] = z - d[x];
}
int n, m;
signed main() {
  scanf("%d%d", &n, &m);
  UFSinit(n + 1);
  for (int i = 1; i <= m; ++i) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    if (UFSfind(x) == UFSfind(y)) {
      if (d[x] - d[y] != z) {
        puts("No");
        return 0;
      }
    } else {
      UFSmerge(x, y, z);
    }
  }
  puts("Yes");
  return 0;
}
