#include <bits/stdc++.h>
using namespace std;
const int64_t mod = 1e9 + 7;
void dbg() { cerr << "\n"; }
template <typename T, typename... T2>
void dbg(const T& fst, const T2&... rst) {
  cerr << fst << ": ";
  dbg(rst...);
}
vector<pair<int, int64_t>> rg[100005], lf[100005];
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> r(m), l(m), d(m);
  for (int(i) = 0; (i) < (m); (i)++) cin >> l[i] >> r[i] >> d[i];
  map<pair<int, int>, int> mp;
  for (int(i) = 0; (i) < (m); (i)++) {
    if (mp.count(pair<int, int>(l[i], r[i])) &&
        d[i] != mp[pair<int, int>(l[i], r[i])]) {
      puts("No");
      return 0;
    }
    if (mp.count(pair<int, int>(r[i], l[i]))) {
      puts("No");
      return 0;
    }
    mp[pair<int, int>(l[i], r[i])] = d[i];
    lf[r[i]].emplace_back(l[i], d[i]);
    rg[l[i]].emplace_back(r[i], d[i]);
  }
  for (int(i) = 0; (i) < (100001); (i)++)
    if ((int)(lf[i]).size() > 0 && (int)(rg[i]).size() > 0) {
      for (auto zl : lf[i]) {
        for (auto zr : rg[i]) {
          int cl = zl.first;
          int cr = zr.first;
          int64_t sm = zl.second + zr.second;
          if (mp.count(pair<int, int>(cl, cr)) &&
              sm != mp[pair<int, int>(cl, cr)]) {
            puts("No");
            return 0;
          }
          if (mp.count(pair<int, int>(cr, cl))) {
            puts("No");
            return 0;
          }
          mp[pair<int, int>(cl, cr)] = sm;
        }
      }
    }
  puts("Yes");
  return 0;
}
