#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;
  vector<stat> stats;
  for (long long i = 0; i < m; i++) {
    stat s;
    cin >> s.p >> s.q >> s.d;
    if (s.p > s.q) {
      s.d = -s.d;
      swap(s.p, s.q);
    }
    stats.emplace_back(s);
  }
  sort(stats.begin(), stats.end());
  map<int64_t, int64_t> xs;
  for (auto& e : stats) {
    if (xs.find(e.p) == xs.end()) xs[e.p] = 0;
    if (xs.find(e.q) == xs.end())
      xs[e.q] = xs[e.p] + e.d;
    else if (xs[e.q] != xs[e.p] + e.d) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}
