#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<int> l, r, d;
vector<vector<pair<int, int> > > to;
int main() {
  cin >> n >> m;
  l.resize(m);
  r.resize(m);
  d.resize(m);
  to.resize(n);
  for (int i = 0; i < m; i++) {
    cin >> l[i] >> r[i] >> d[i];
    l[i]--;
    r[i]--;
    to[l[i]].push_back(make_pair(r[i], d[i]));
    to[r[i]].push_back(make_pair(l[i], -d[i]));
  }
  vector<bool> flg(n, false);
  long long INF = 100000LL * 10000LL + 1;
  vector<long long> x(n, INF);
  for (int i = 0; i < n; i++) {
    if (flg[i]) continue;
    flg[i] = true;
    x[i] = 0;
    queue<pair<int, long long> > toSearch;
    for (auto obj : to[i]) {
      toSearch.push(make_pair(obj.first, obj.second));
      flg[obj.first] = true;
    }
    while (!toSearch.empty()) {
      int st = toSearch.front().first;
      long long xtmp = toSearch.front().second;
      toSearch.pop();
      flg[st] = true;
      x[st] = xtmp;
      for (auto nxt : to[st]) {
        if (!flg[nxt.first])
          toSearch.push(make_pair(nxt.first, xtmp + (long long)nxt.second));
      }
    }
  }
  for (int j = 0; j < m; j++) {
    if (x[r[j]] - x[l[j]] != d[j]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
