#include <bits/stdc++.h>
signed main() {
  std::ios::sync_with_stdio(false);
  int N, M;
  std::cin >> N >> M;
  std::vector<int> vis(N);
  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::queue<int> que;
  ans[L[0] - 1] = 0;
  ans[R[0] - 1] = D[0];
  vis[L[0] - 1] = vis[R[0] - 1] = 1;
  que.emplace(L[0] - 1);
  que.emplace(R[0] - 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 (vis[v]) {
        if (ans[u] + d != ans[v]) {
          std::cout << "No" << std::endl;
          exit(0);
        }
      } else {
        ans[v] = ans[u] + d;
        que.emplace(v);
        vis[v] = 1;
      }
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}
