#include <bits/stdc++.h>
using namespace std;
inline int min(int _a, int _b) { return _a < _b ? _a : _b; }
inline int max(int _a, int _b) { return _a > _b ? _a : _b; }
template <class _T>
inline void rd(_T &_a) {
  int _f = 0, _ch = getchar();
  _a = 0;
  while (_ch < '0' || _ch > '9') {
    if (_ch == '-') _f = 1;
    _ch = getchar();
  }
  while (_ch >= '0' && _ch <= '9')
    _a = (_a << 1) + (_a << 3) + _ch - '0', _ch = getchar();
  if (_f) _a = -_a;
}
const int inf = 0x3f3f3f3f;
const double eps = 1e-8;
const int N = 1e5 + 5;
int fl, p[N], s[N];
int getf(int i) {
  if (!p[i]) return i;
  int t = getf(p[i]);
  s[i] += s[p[i]];
  return p[i] = t;
}
void merge(int u, int v, int w) {
  int fx = getf(u), fy = getf(v);
  if (fx != fy)
    p[fx] = v, s[fx] = s[fy] - s[fx] - w;
  else if (s[v] - s[u] != w)
    fl = 1;
}
int main() {
  int n, m;
  rd(n);
  rd(m);
  for (int u, v, w; m; m--) rd(u), rd(v), rd(w), merge(u, v, w);
  puts(fl ? "No" : "Yes");
  return 0;
}
