#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int s = 0, f = 1;
  char ch = getchar();
  while (!('0' <= ch && ch <= '9') && ch != '-') ch = getchar();
  if (ch == '-') ch = getchar(), f = -1;
  while ('0' <= ch && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * f;
}
const int maxn = 1e5 + 20;
long long n, fa[maxn], m;
long long w[maxn];
void init() {
  n = read();
  for (long long i = (1), _end_ = (n); i <= _end_; i++) fa[i] = i, w[i] = 0;
  m = read();
}
long long fin(long long x) {
  if (x == fa[x]) return x;
  long long p = fin(fa[x]);
  w[x] += w[fa[x]];
  return fa[x] = p;
}
void doing() {
  for (long long i = (1), _end_ = (m); i <= _end_; i++) {
    long long u = read(), v = read(), W = read();
    long long x = fin(u), y = fin(v);
    if (x == y) {
      if (w[u] - w[v] != W) {
        printf("No\n");
        return;
      }
    } else {
      fa[x] = y;
      w[x] = W;
    }
  }
  puts("Yes");
}
int main() {
  init();
  doing();
  return 0;
}
