#include <bits/stdc++.h>
int main(int argc, char** argv) {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);
  std::cout << std::fixed << std::setprecision(6);
  int N, M, L, R, D;
  std::cin >> N >> M;
  std::vector<std::vector<std::pair<int, int>>> G(N);
  for (int i = 0; i < M; i++) {
    std::cin >> L >> R >> D;
    L--;
    R--;
    G[L].emplace_back(R, D);
    G[R].emplace_back(L, -D);
  }
  long long a[111111];
  std::fill(a, a + N, -4000000000000000000LL);
  a[0] = 0;
  for (int i = 0; i < N; i++)
    for (const auto& e : G[i]) {
      int x = a[i] + e.second;
      if (a[e.first] == -4000000000000000000LL) {
        a[e.first] = x;
      } else if (a[e.first] != x) {
        std::cout << "No" << std::endl;
        return 0;
      }
    }
  std::cout << "Yes" << std::endl;
  return 0;
}
