#include <bits/stdc++.h>
using namespace std;
map<long long, long long> t;
map<long long, vector<pair<long long, long long> > > g;
int main() {
  long long n, m, l, r, d;
  cin >> n >> m;
  for (int i = (0); i < (m); ++i) {
    cin >> l >> r >> d;
    --l, --r;
    g[l].emplace_back(make_pair(r, d));
  }
  for (auto it : g) {
    for (int i = (0); i < (it.second.size()); ++i) {
      long long l = it.first, r = it.second[i].first, d = it.second[i].second;
      if (t.count(l) == 0 && t.count(r) == 0)
        t[l] = 0, t[r] = d;
      else if (t.count(l) > 0 && t.count(r) == 0)
        t[r] = t[l] + d;
      else if (t.count(l) == 0 && t.count(r) > 0)
        t[l] = t[r] - d;
      else {
        if (t[r] - t[l] != d) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
