#include <bits/stdc++.h>
int d[120000], f[120000], h[120000];
int i, m, n, x, y, dx, dy, fx, fy, z;
inline int getfather(int x) {
  if (f[x] == x)
    return x;
  else
    return getfather(f[x]);
}
inline int getdis(int x) {
  if (f[x] == x)
    return 0;
  else
    return d[x] + getdis(f[x]);
}
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) f[i] = i, h[i] = 1;
  for (i = 1; i <= m; i++) {
    scanf("%d%d%d", &x, &y, &z);
    fx = getfather(x);
    fy = getfather(y);
    if (fx != fy)
      if (h[fx] < h[fy])
        d[fx] = z - getdis(x) + getdis(y), f[fx] = fy, h[fx] = h[fx] + h[fy];
      else
        d[fy] = -z - getdis(y) + getdis(x), f[fy] = fx, h[fy] = h[fy] + h[fx];
    else {
      dx = getdis(x);
      dy = getdis(y);
      if (dx != dy + z) return puts("No"), 0;
    }
  }
  return puts("Yes"), 0;
}
