#include <bits/stdc++.h>
using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
int main(void) {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  uint32 n, m;
  std::cin >> n >> m;
  uint32 l, r;
  int64 d;
  std::vector<std::vector<std::pair<uint32, int64>>> D(n);
  for (uint32 i = 0; i < m; ++i) {
    std::cin >> l >> r >> d;
    D[l - 1].push_back({r - 1, d});
    D[r - 1].push_back({l - 1, -d});
  }
  std::vector<int64> x(n, INT_FAST64_MIN);
  x[0] = 0;
  std::vector<char> re(n, 0);
  std::queue<uint32> Q;
  std::set<uint32> S;
  for (uint32 i = 0; i < n; ++i) {
    S.insert(i);
  }
  Q.push(0);
  while (!S.empty()) {
    if (Q.empty()) {
      Q.push(*S.begin());
      x[*S.begin()] = 0;
      S.erase(S.begin());
    }
    uint32 t = Q.front();
    Q.pop();
    if (re[t]) continue;
    S.erase(t);
    for (uint32 i = 0; i < D[t].size(); ++i) {
      if (x[D[t][i].first] == INT_FAST64_MIN) {
        x[D[t][i].first] = x[t] + D[t][i].second;
      } else {
        if (x[D[t][i].first] != x[t] + D[t][i].second) {
          std::cout << "No\n";
          return 0;
        }
      }
      if (!re[D[t][i].first]) {
        Q.push(D[t][i].first);
      }
    }
  }
  std::cout << "Yes\n";
  return 0;
}
