#include <bits/stdc++.h>
using namespace std;
class stat {
 public:
  int64_t p, q, d;
  bool operator<(const stat& e) const {
    if (this->p == e.p) return this->q < e.q;
    return this->p < e.p;
  }
};
int main(void) {
  int64_t n, m;
  cin >> n >> m;
  list<stat> stats;
  for (long long i = 0; i < m; i++) {
    stat s;
    cin >> s.p >> s.q >> s.d;
    stats.emplace_back(s);
    swap(s.p, s.q);
    s.d = -s.d;
    stats.emplace_back(s);
  }
  map<int64_t, int64_t> xs;
  while (!stats.empty()) {
    bool update = false;
    xs.clear();
    xs[stats.begin()->p] = 0;
    while (true) {
      update = false;
      for (auto e = stats.begin(); e != stats.end();) {
        if (xs.find(e->p) != xs.end()) {
          if (xs.find(e->q) != xs.end()) {
            if (xs[e->q] != xs[e->p] + e->d) {
              cout << "No";
              return 0;
            } else {
              e++;
            }
          } else {
            xs[e->q] = xs[e->p] + e->d;
            e = stats.erase(e);
            update = true;
          }
        } else {
          e++;
        }
      }
      if (!update) break;
    }
  }
  cout << "Yes";
  return 0;
}
