#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, m;
  cin >> n >> m;
  vector<long> L(m);
  vector<long> R(m);
  vector<long> D(m);
  vector<long> x(n);
  vector<bool> set(n, false);
  for (int i = 0; i < m; i++) {
    cin >> L[i] >> R[i] >> D[i];
    if (L[i] > R[i]) {
      swap(L[i], R[i]);
      D[i] = -D[i];
    }
  }
  vector<long> sor(m);
  for (int i = 0; i < m; i++) sor[i] = (long)i + (long)(L[i] << 20);
  sort(sor.begin(), sor.end());
  for (int i = 0; i < m; i++) sor[i] = sor[i] & (long)262143;
  long t;
  for (int i = 0; i < m; i++) {
    t = sor[i];
    if (set[R[t] - 1] && (x[R[t] - 1] != x[L[t] - 1] + D[t])) {
      cout << "No" << endl;
      return 0;
    } else {
      x[R[t] - 1] = x[L[t] - 1] + D[t];
      set[R[t] - 1] = true;
    }
  }
  cout << "Yes" << endl;
}
