#include <bits/stdc++.h>
using namespace std;
pair<int, long long> root[200010];
int parent(int i) {
  if (root[i].first == i) {
    return i;
  }
  return parent(root[i].first);
}
long long distance(int i) {
  if (root[i].first == i) {
    return 0;
  }
  return root[i].second + distance(root[i].first);
}
int main() {
  int n, m;
  cin >> n >> m;
  int l[200010];
  int r[200010];
  long long d[200010];
  for (int i = 1; i <= m; i++) {
    cin >> l[i] >> r[i] >> d[i];
  }
  for (int i = 1; i <= n; i++) {
    root[i].first = i;
    root[i].second = 0;
  }
  for (int i = 1; i <= m; i++) {
    if (r[i] < l[i]) {
      int copy = r[i];
      r[i] = l[i];
      l[i] = copy;
      d[i] = -d[i];
    }
    if (parent(l[i]) == parent(r[i])) {
      if ((distance(l[i]) + d[i]) != distance(r[i])) {
        cout << "No" << endl;
        return 0;
      }
      continue;
    }
    root[r[i]].second = d[i] + distance(l[i]);
    root[r[i]].first = parent(l[i]);
  }
  cout << "Yes" << endl;
  return 0;
}
