#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

template <class T> inline bool chmin(T &a, const T &b) {
  return (a > b) ? a = b, true : false;
}

template <class T> inline bool chmax(T &a, const T &b) {
  return (a < b) ? a = b, true : false;
}

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  int N, M;
  std::cin >> N >> M;
  std::vector<int> L(M);
  std::vector<int> R(M);
  std::vector<int> D(M);
  for (int i = 0; i < M; ++i) {
    std::cin >> L[i] >> R[i] >> D[i];
    --L[i], --R[i];
  }

  // Main
  std::vector<int> dist(N, IINF);
  bool res = true;
  for (int i = 0; i < M; ++i) {
    if (dist[L[i]] == IINF and dist[R[i]] == IINF) {
      dist[L[i]] = 0;
      dist[R[i]] = D[i];
      continue;
    }
    if (dist[R[i]] == IINF) {
      dist[R[i]] = dist[L[i]] + D[i];
      continue;
    }
    if (dist[L[i]] == IINF) {
      dist[L[i]] = dist[R[i]] - D[i];
      continue;
    }
    if (dist[R[i]] - dist[L[i]] != D[i]) {
      // std::cout << dist[L[i]] - dist[R[i]] << std::endl;
      // std::cout << D[i] << std::endl;
      res = false;
      break;
    }
  }

  if (res)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;

  return 0;
}
