#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> L(M), R(M), D(M);
  for (long long i = 0; i < M; ++i) cin >> L[i] >> R[i] >> D[i];
  vector<long long> x(N);
  vector<bool> y(N, false);
  for (long long i = 0; i < M; ++i) {
    if ((y[L[i] - 1] == false) && (y[R[i] - 1] == false)) {
      x[L[i] - 1] = 0;
      x[R[i] - 1] = D[i];
      y[L[i] - 1] = true;
      y[R[i] - 1] = true;
    }
    if ((y[L[i] - 1] == true) && (y[R[i] - 1] == false)) {
      x[R[i] - 1] = x[L[i] - 1] + D[i];
      y[R[i] - 1] = true;
    }
    if ((y[L[i] - 1] == false) && (y[R[i] - 1] == true)) {
      x[L[i] - 1] = x[R[i] - 1] - D[i];
      y[L[i] - 1] = true;
    }
    if ((y[L[i] - 1] == true) && (y[R[i] - 1] == true)) {
      if (x[R[i] - 1] - x[L[i] - 1] != D[i]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
