#include <bits/stdc++.h>
using namespace std;
int n, m;
int main() {
  cin >> n >> m;
  vector<vector<pair<int, int> > > ed(n + 1, vector<pair<int, int> >(0));
  map<pair<int, int>, int> pairs, pairs2;
  vector<int> c(n + 1, 0);
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    ed[l].push_back({r, d});
    ed[r].push_back({l, -d});
    pairs[{l, r}] = d;
  }
  pairs2 = pairs;
  bool yes = true;
  while (pairs.begin() != pairs.end() && yes) {
    int l, r;
    l = pairs.begin()->first.first;
    c[l] = 1;
    queue<pair<int, int> > edgs;
    for (int i = 0; i < ed[l].size(); i++) {
      if (pairs.count({l, ed[l][i].first})) {
        edgs.push({l, ed[l][i].first});
        pairs.erase({l, ed[l][i].first});
      }
    }
    while (edgs.size()) {
      pair<int, int> p = edgs.front();
      edgs.pop();
      int d = pairs2[{p.first, p.second}];
      if (c[p.first]) {
        if (c[p.second]) {
          if (c[p.second] - c[p.first] != d) {
            yes = false;
            break;
          }
        } else {
          c[p.second] = c[p.first] + d;
        }
      } else {
        if (c[p.second]) {
          c[p.first] = c[p.second] - d;
        } else {
        }
      }
      if (!yes) break;
      int l = p.second;
      for (int i = 0; i < ed[l].size(); i++) {
        if (pairs.count({l, ed[l][i].first})) {
          edgs.push({l, ed[l][i].first});
          pairs.erase({l, ed[l][i].first});
        }
      }
    }
  }
  if (yes)
    cout << "Yes\n";
  else
    cout << "No\n";
}
