#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, L, R, D;
  long long x[100000] = {};
  bool fix[100000] = {};
  cin >> N >> M;
  bool ok = true;
  long long x_max = 0;
  for (int i = 0; i < (M); i++) {
    cin >> L >> R >> D;
    if (!ok) continue;
    fix[L] = true;
    if (!fix[R]) {
      fix[R] = true;
      x[R] = x[L] + D;
      x_max = max(x_max, x[R]);
    } else if (fix[R] && x[R] - x[L] != D) {
      ok = false;
    }
  }
  if (ok && x_max <= 1000000000)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
