#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
signed main(void) {
  cin.sync_with_stdio(false);
  cin.tie(0);
  long long N, M;
  cin >> N >> M;
  ;
  if (M == 0) {
    cout << "Yes" << '\n';
    return 0;
  }
  vector<vector<pair<long long, long long> > > out(N);
  for (long long i = 0; i < M; i++) {
    long long l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    out[l].push_back(make_pair(r, d));
    out[r].push_back(make_pair(l, -d));
  }
  bool used[N];
  long long d[N];
  fill(used, used + N, false);
  fill(d, d + N, 0);
  for (long long i = 0; i < N; i++) {
    used[i] = true;
    if (out[i].size() == 0) continue;
    for (auto &e : out[i]) {
      if (used[e.first]) {
        if (d[e.first] != d[i] + e.second) {
          cout << "No" << '\n';
          return 0;
        }
      } else {
        used[e.first] = true;
        d[e.first] = d[i] + e.second;
      }
    }
  }
  cout << "Yes" << '\n';
  return 0;
}
