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