#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;
template <class T>
void vin(vector<T>& v, int n) {
  v.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
}
int N, M;
struct E {
  ll l, r, d;
};
bool used[101010];
ll dist[101010];
vector<E> e[101010];
vector<pair<int, int>> p;
int main() {
  cin >> N >> M;
  p.resize(N + 1);
  for (int(i) = (0); (i) < (int)(N); ++(i)) {
    p[i] = {0, i};
  }
  bool ok = true;
  for (int(i) = (0); (i) < (int)(M); ++(i)) {
    ll l, r, d;
    cin >> l >> r >> d;
    if (l > r) {
      swap(l, r);
      d = -d;
    }
    e[l].push_back({l, r, d});
    p[l].first++;
    p[r].first++;
  }
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  for (int(i) = (0); (i) < (int)(N + 1); ++(i)) {
    int n = p[i].second;
    for (auto& a : e[n]) {
      ll l = a.l, r = a.r, d = a.d;
      if (!used[l] and !used[r]) {
        dist[l] = 0;
        dist[r] = d;
        used[l] = true;
        used[r] = true;
      } else if (used[l] and !used[r]) {
        dist[r] = dist[l] + d;
        used[r] = true;
      } else if (used[r] and !used[l]) {
        dist[l] = dist[r] - d;
        used[l] = true;
      } else {
        if (dist[r] - dist[l] != d) {
          ok = false;
          break;
        }
      }
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
}
