#include <bits/stdc++.h>
using namespace std;
struct edge {
  int from, to;
  long long cost;
};
int main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, l, r, d;
  cin >> n >> m;
  if (m == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  vector<pair<pair<int, int>, int> > rules(m);
  for (int i = 0; i < m; i++) {
    cin >> l >> r >> d;
    if (l > r) {
      swap(l, r);
      d *= -1;
    }
    rules[i] = pair<pair<int, int>, int>(pair<int, int>(l - 1, r - 1), d);
  }
  sort(rules.begin(), rules.end());
  int pos[n];
  fill(pos, pos + n, INT_MAX);
  for (int i = 0; i < m; i++) {
    d = rules[i].second;
    l = rules[i].first.first;
    r = rules[i].first.second;
    if (pos[l] != INT_MAX) {
      pos[r] = pos[l] + d;
    } else if (pos[r] != INT_MAX) {
      pos[l] = pos[r] - d;
    } else {
      pos[l] = 0;
      pos[r] = d;
    }
  }
  for (int i = 0; i < m; i++) {
    d = rules[i].second;
    l = rules[i].first.first;
    r = rules[i].first.second;
    if (pos[r] - pos[l] != d) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
