#include <bits/stdc++.h>
using namespace std;
bool done[123456];
pair<int, long long> uf[123456];
vector<int> chld[123456];
int main(void) {
  int n, m, l, r, i;
  long long d;
  bool flag = true;
  fill(done, done + 123456, false);
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> l >> r >> d;
    if (done[l] && done[r]) {
      if (uf[l].first == uf[r].first) {
        if (uf[l].second + d != uf[r].second) {
          flag = false;
        }
      } else {
        for (i = (chld[r].size() - 1); i >= 0; i--) {
          uf[chld[r][i]].first = l;
          uf[chld[r][i]].second += d;
          chld[l].push_back(chld[r][i]);
        }
      }
    } else if (done[l]) {
      uf[r].first = uf[l].first;
      uf[r].second = uf[l].second + d;
      done[r] = true;
      chld[l].push_back(r);
    } else if (done[r]) {
      uf[l].first = uf[r].first;
      uf[l].second = uf[r].second - d;
      done[l] = true;
      chld[r].push_back(l);
    } else {
      uf[l].first = l;
      uf[l].second = 0ll;
      uf[r].first = l;
      uf[r].second = d;
      done[l] = true;
      done[r] = true;
      chld[l].push_back(r);
    }
  }
  cout << ((flag) ? "Yes" : "No") << endl;
  return 0;
}
