#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll d[100001][2];
pair<ll, ll> search_root_diff(ll i) {
  cerr << i << ' ' << d[i][0] << ' ' << d[i][1] << endl;
  if (d[i][0] == i) return make_pair(i, 0);
  ll df = d[i][1];
  auto r = search_root_diff(d[i][0]);
  r.second += df;
  d[i][0] = r.first;
  d[i][1] = r.second;
  return r;
}
int main() {
  ll N, M;
  cin >> N >> M;
  for (ll i = 0; i < N + 1; i++) {
    d[i][0] = i;
    d[i][1] = 0;
  }
  bool ok = true;
  for (ll i = 0; i < M; i++) {
    ll L, R, D;
    cin >> L >> R >> D;
    auto r1 = search_root_diff(L);
    auto r2 = search_root_diff(R);
    if (r1.first == r2.first) {
      if (r2.second - r1.second != D) {
        ok = false;
        break;
      }
    }
    if (r1.second <= r2.second - D) {
      d[r2.second][0] = r1.first;
      d[r2.second][1] = r1.second + D - r2.second;
      d[R][0] = r1.second;
      d[R][1] = r1.second + D;
    } else {
      d[r1.second][0] = r2.first;
      d[r1.second][1] = r2.second - D - r1.second;
      d[L][0] = r2.second;
      d[L][1] = r2.second - D;
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
}
