#include <bits/stdc++.h>
using namespace std;
long long par[100000];
long long weight[100010] = {0};
long long root(long long x) {
  if (par[x] == x) {
    return x;
  } else {
    weight[x] += weight[par[x]];
    return par[x] = root(par[x]);
  }
}
signed main() {
  long long n, q, a, b;
  long long w;
  long long x, y;
  cin >> n >> q;
  for (long long i = 0; i < n; i++) {
    par[i] = i;
  }
  for (long long j = 0; j < q; j++) {
    cin >> a >> b >> w;
    x = root(a);
    y = root(b);
    if (x == y) {
      if (weight[y] == w) {
        continue;
      } else {
        cout << "No" << endl;
        return 0;
      }
    } else {
      w += weight[x];
      w -= weight[y];
      par[x] = y;
      weight[y] = w;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
