#include <bits/stdc++.h>
using namespace std;
class UnionFind {
 public:
  explicit UnionFind(int N) {
    m_par.reserve(N);
    for (int n = 0; n < N; ++n) {
      m_par.push_back(n);
    }
    m_dist = vector<int>(N);
  }
  int Root(int n) {
    if (n == m_par[n]) return n;
    m_dist[n] = m_dist[n] + m_dist[m_par[n]];
    return m_par[n] = Root(m_par[n]);
  }
  bool Unite(int n, int m, int d) {
    if (Root(n) == Root(m)) {
      if (m_dist[m] - m_dist[n] == d)
        return true;
      else
        return false;
    }
    m_dist[Root(n)] = -d;
    m_par[Root(n)] = Root(m);
    return true;
  }
  bool Same(int n, int m) { return Root(n) == Root(m); }

 private:
  vector<int> m_par;
  vector<int> m_dist;
};
int main(int argc, const char* argv[]) {
  ios_base::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  UnionFind UF(N);
  for (int m = 0; m < M; ++m) {
    int l, r, d;
    cin >> l >> r >> d;
    --l;
    --r;
    if (!UF.Unite(l, r, d)) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}
