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