#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> root(n);
  vector<vector<int>> subset(n);
  vector<int> dist(n);
  for (int i = 0; i < n; ++i) {
    root[i] = i;
    subset[i] = {i};
    dist[i] = 0;
  }
  for (int i = 0; i < m; ++i) {
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    if (root[l] == root[r]) {
      if (dist[r] - dist[l] != d) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      int src, dst, diff;
      if (subset[root[l]].size() < subset[root[r]].size()) {
        src = root[l];
        dst = root[r];
        diff = -d + dist[r];
      } else {
        src = root[r];
        dst = root[l];
        diff = d + dist[l];
      }
      for (auto &&idx : subset[src]) {
        root[idx] = dst;
        subset[dst].push_back(idx);
        dist[idx] += diff;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
