#include <bits/stdc++.h>
using namespace std;
long long n, m, l, r, d, fa[200001], ra[200001], diff_weight[200001];
long long find(long long x) {
  if (fa[x] == x) return x;
  diff_weight[x] += diff_weight[fa[x]];
  return fa[x] = find(fa[x]);
}
long long weight(long long x) {
  find(x);
  return diff_weight[x];
}
bool uni(long long x, long long y, long long w) {
  w += weight(x), w -= weight(y);
  x = find(x);
  y = find(y);
  if (x == y) return false;
  if (ra[x] < ra[y]) {
    swap(x, y);
    w = -w;
  }
  fa[y] = x;
  if (ra[x] == ra[y]) ra[x]++;
  diff_weight[y] = w;
  return true;
}
int main(void) {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 0; i < m; i++) {
    cin >> l >> r >> d;
    if (find(l) != find(r))
      uni(l, r, d);
    else {
      if (weight(r) - weight(l) != d) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}
