#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<int, pair<int, int> > > rules(m);
  for (int i = 0; i < m; i++) {
    cin >> l >> r >> d;
    rules[i] = pair<int, pair<int, int> >(d, pair<int, int>(l - 1, r - 1));
  }
  sort(rules.begin(), rules.end());
  map<int, int> mp[n];
  for (int i = 0; i < m; i++) {
    d = rules[i].first;
    l = rules[i].second.first;
    r = rules[i].second.second;
    for (auto itr = mp[l].begin(); itr != mp[l].end(); ++itr) {
      if (mp[itr->first].find(r) == mp[itr->first].end()) continue;
      if (itr->second + mp[itr->first][r] != d) {
        cout << "No" << endl;
        return 0;
      }
    }
    mp[l][r] = d;
    mp[r][l] = -d;
  }
  cout << "Yes" << endl;
  return 0;
}
