#include <bits/stdc++.h>
const int INF = ~(1 << 31);
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int hito[n + 1];
  memset(hito, -1, sizeof(hito));
  vector<pair<pair<int, int>, int> > vec(m);
  int l, r, d;
  for (int i = 0; i < m; ++i) {
    cin >> l >> r >> d;
    vec[i] = make_pair(make_pair(l, r), d);
  }
  hito[vec[0].first.first] = 0;
  for (int i = 0; i < m; ++i) {
    if (hito[vec[i].first.second] == -1) {
      hito[vec[i].first.second] = hito[vec[i].first.first] + vec[i].second;
      if (hito[vec[i].first.second] > 1000000000) {
        cout << "No" << endl;
        ;
        return 0;
      }
    } else {
      if (hito[vec[i].first.second] ==
          hito[vec[i].first.first] + vec[i].second) {
        continue;
      } else {
        cout << "No" << endl;
        ;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  ;
  return 0;
}
