#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (const auto &v : vec) {
    os << v << ",";
  }
  os << "]";
  return os;
}
void solve() {
  int N, M;
  cin >> N >> M;
  vector<i64> x(N, -inf64);
  bool ok = true;
  for (i64 i = i64(0), i_max_for_repmacro = i64(M); i < i_max_for_repmacro;
       ++i) {
    int L, R;
    i64 D;
    cin >> L >> R >> D;
    --L;
    --R;
    if (x[L] == -inf64 and x[R] == -inf64) {
      x[L] = 0;
      x[R] = D;
    } else if (x[L] == -inf64 and x[R] != -inf64) {
      x[L] = x[R] - D;
    } else if (x[L] != -inf64 and x[R] == -inf64) {
      x[R] = x[L] + D;
    } else {
      if (x[L] + D != x[R]) {
        ok = false;
      }
    }
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}
