#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template <class T = int>
using V = vector<T>;
template <class T = int>
using VV = V<V<T> >;
template <class T>
void assign(V<T>& v, int n, const T& a = T()) {
  v.assign(n, a);
}
template <class T, class... U>
void assign(V<T>& v, int n, const U&... u) {
  v.resize(n);
  for (auto&& i : v) assign(i, u...);
}
struct A {
  using T = int;
  static constexpr T e() { return 0; }
};
template <class A>
struct WQU {
  using T = typename A::T;
  V<> par, rank, _size;
  V<T> _diff;
  WQU(int n) {
    par.resize(n);
    iota(par.begin(), par.end(), 0);
    rank.resize(n);
    _size.assign(n, 1);
    _diff.assign(n, A::e());
  }
  T diff(int a, int b) {
    find(a), find(b);
    return _diff[b] - _diff[a];
  }
  int find(int a) {
    if (par[a] == a)
      return a;
    else {
      int t = find(par[a]);
      _diff[a] += _diff[par[a]];
      return par[a] = t;
    }
  }
  bool same(int a, int b) { return find(a) == find(b); }
  int size(int a) { return _size[find(a)]; }
  void unite(int a, int b, T& d) {
    d -= diff(a, b);
    a = find(a), b = find(b);
    if (rank[a] < rank[b]) {
      par[a] = b;
      _size[b] += _size[a];
      _diff[a] = d;
    } else {
      par[b] = a;
      _size[a] += _size[b];
      _diff[b] = d;
    }
    if (rank[a] == rank[b]) rank[a]++;
  }
};
int main() {
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  WQU<A> w(n);
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d, l--, r--;
    if (w.same(l, r) and w.diff(l, r) != d) return cout << "No" << '\n', 0;
    if (!w.same(l, r)) w.unite(l, r, d);
  }
  cout << "Yes" << '\n';
}
