#include <bits/stdc++.h>
using namespace std;
int N, M;
long long TBD = -1e18;
int main() {
  cin >> N >> M;
  vector<long long> x(N + 1, TBD);
  map<pair<int, int>, int> dist;
  for (int i = 0; i < M; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    if (l > r) {
      swap(l, r);
      d = -d;
    }
    dist[make_pair(l, r)] = d;
  }
  x[1] = 0;
  for (auto itr = dist.begin(); itr != dist.end(); ++itr) {
    int l = (*itr).first.first, r = (*itr).first.second, d = (*itr).second;
    if (x[l] == TBD) x[l] = 0;
    if (x[r] != TBD && x[r] != x[l] + d) {
      cout << "No" << endl;
      return 0;
    }
    x[r] = x[l] + d;
  }
  cout << "Yes" << endl;
}
