#include <bits/stdc++.h>
long long int N, M;
std::vector<long long int> pos;
std::vector<std::pair<std::pair<long long int, long long int>, long long int>>
    dat;
int main() {
  std::cin >> N >> M;
  dat.resize(M);
  pos.resize(N + 1);
  for (int i = 0; i < M; ++i) {
    std::cin >> dat[i].first.first >> dat[i].first.second >> dat[i].second;
  }
  std::sort(dat.begin(), dat.end());
  std::fill(pos.begin(), pos.end(), -1);
  if (M > 0) {
    pos[dat[0].first.first] = 0;
    for (int i = 0; i < M; ++i) {
      auto l = dat[i].first.first, r = dat[i].first.second, d = dat[i].second;
      if (pos[r] == -1 || (pos[r] - pos[l]) == d) {
        if (pos[l] == -1) pos[l] = 0;
        pos[r] = pos[l] + d;
      } else {
        std::cout << "No" << std::endl;
        return 0;
      }
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}
