#include <bits/stdc++.h>
constexpr long long mod = static_cast<long long>(1e9 + 7);
struct Edge {
  int to;
  int w;
};
int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<std::vector<Edge>> edges(N, std::vector<Edge>());
  std::vector<int> counts(N, 0);
  while (M--) {
    int l, r, d;
    std::cin >> l >> r >> d;
    --l;
    --r;
    ++counts[r];
    edges[l].push_back(Edge{r, d});
  }
  bool ans = true;
  for (int i = 0; i < N; ++i) {
    if (counts[i] == 0 && !edges[i].empty()) {
      std::vector<long long> memo(N, std::numeric_limits<long long>::max());
      memo[i] = 0;
      std::queue<std::pair<int, long long>> que;
      que.push(std::make_pair(i, 0));
      while (!que.empty() && ans) {
        auto now = que.front();
        que.pop();
        int v = now.first;
        long long w = now.second;
        for (auto edge : edges[v]) {
          if (memo[edge.to] == std::numeric_limits<long long>::max()) {
            memo[edge.to] = edge.w + w;
            que.push(std::make_pair(edge.to, w + edge.w));
          } else {
            if (memo[edge.to] != edge.w + w) {
              ans = false;
              break;
            }
          }
        }
      }
    }
  }
  if (ans)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;
  return 0;
}
