#include <bits/stdc++.h>
using Pair = std::pair<long long, int>;
int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<long long> l(m), r(m), d(m);
  for (int mi = 0; mi < m; ++mi) std::cin >> l[mi] >> r[mi] >> d[mi];
  std::vector<std::vector<Pair>> edges(n);
  for (int mi = 0; mi < m; ++mi) {
    edges[l[mi] - 1].push_back(Pair(d[mi], r[mi] - 1));
    edges[r[mi] - 1].push_back(Pair(-d[mi], l[mi] - 1));
  }
  std::vector<int> has_visited(n, false);
  for (int ni = 0; ni < n; ++ni) {
    if (has_visited[ni]) continue;
    std::queue<Pair> q;
    std::map<long long, int> line;
    has_visited[ni] = true;
    line[0] = ni;
    q.push(Pair(0, ni));
    while (not q.empty()) {
      long long pos = q.front().first;
      int nj = q.front().second;
      q.pop();
      for (auto e : edges[nj]) {
        long long npos = pos + e.first;
        int nk = e.second;
        if (has_visited[nk]) {
          if ((not line.count(npos)) or line[npos] != nk) {
            std::cout << "No" << std::endl;
            return 0;
          }
        } else {
          line[npos] = nk;
          has_visited[nk] = true;
          q.push(Pair(npos, nk));
        }
      }
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}
