#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, m;
  cin >> n >> m;
  long long a[n + 1];
  bool used[n + 1];
  fill(a, a + n + 1, 0);
  fill(used, used + n + 1, false);
  for (long long i = 0; i < m; i++) {
    long long l, r, d;
    cin >> l >> r >> d;
    if (used[l] && used[r] && a[r] - a[l] != d) {
      cout << "No" << endl;
      return 0;
    }
    used[l] = used[r] = true;
    a[r] = a[l] + d;
  }
  cout << "Yes" << endl;
  return 0;
}
