#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int main() {
  fast();
  int n, m;
  cin >> n >> m;
  map<int, int> vis;
  int l, r, d;
  vector<pair<int, pair<int, int>>> v(m);
  for (int i = 0; i < m; i++) {
    cin >> l >> r >> d;
    if (l > r) swap(l, r);
    v[i].first = l;
    v[i].second.first = r;
    v[i].second.second = d;
  }
  sort((v).begin(), (v).end());
  for (int i = 0; i < m; i++) {
    if (vis[v[i].second.first] &&
        vis[v[i].second.first] != vis[v[i].first] + v[i].second.second) {
      cout << "No" << endl;
      return 0;
    }
    vis[v[i].second.first] = vis[v[i].first] + v[i].second.second;
  }
  vector<pair<int, int>> v1((vis).begin(), (vis).end());
  for (int i = 1; i < v1.size(); i++) {
    if (v1[i].second < v1[i - 1].second) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
