#include <bits/stdc++.h>
signed main() {
  std::ios::sync_with_stdio(false);
  int N, M;
  std::cin >> N >> M;
  std::vector<int> ans(N);
  std::vector<int> L(M), R(M), D(M);
  std::vector<std::vector<std::pair<int, int>>> G(N);
  for (int i = 0; i < M; ++i) {
    std::cin >> L[i] >> R[i] >> D[i];
    G[L[i] - 1].emplace_back(D[i], R[i] - 1);
    G[R[i] - 1].emplace_back(-D[i], L[i] - 1);
  }
  if (M == 0) {
    std::cout << "Yes" << std::endl;
    exit(0);
  }
  std::set<int> bag;
  for (int i = 0; i < N; ++i) {
    bag.emplace(i);
  }
  while (!bag.empty()) {
    int k = *bag.begin();
    std::queue<int> que;
    ans[L[k] - 1] = 0;
    ans[R[k] - 1] = D[k];
    bag.erase(L[k] - 1);
    bag.erase(R[k] - 1);
    que.emplace(L[k] - 1);
    que.emplace(R[k] - 1);
    while (!que.empty()) {
      int u = que.front();
      que.pop();
      for (int i = 0; i < G[u].size(); ++i) {
        int d, v;
        std::tie(d, v) = G[u][i];
        if (!bag.count(v)) {
          if (ans[u] + d != ans[v]) {
            std::cout << "No" << std::endl;
            exit(0);
          }
        } else {
          ans[v] = ans[u] + d;
          que.emplace(v);
          bag.erase(v);
        }
      }
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}
