#include <bits/stdc++.h>
using namespace std;
using ll = long long;
class UnionFind {
 private:
  vector<ll> _par;
  vector<ll> _rank;

 public:
  explicit UnionFind(ll n);
  ll find(ll x);
  void unite(ll x, ll y);
  bool isSame(ll x, ll y);
};
UnionFind::UnionFind(ll n) {
  for (ll i = 0; i < n; ++i) {
    _par.push_back(i);
    _rank.push_back(0);
  }
}
ll UnionFind::find(ll x) {
  if (_par.at(static_cast<unsigned long>(x)) == x)
    return x;
  else
    return _par.at(static_cast<unsigned long>(x)) =
               find(_par.at(static_cast<unsigned long>(x)));
}
void UnionFind::unite(ll x, ll y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  if (_rank.at(static_cast<unsigned long>(x)) <
      _rank.at(static_cast<unsigned long>(y)))
    _par.at(static_cast<unsigned long>(x)) = y;
  else {
    _par.at(static_cast<unsigned long>(y)) = x;
    if (_rank.at(static_cast<unsigned long>(x)) ==
        _rank.at(static_cast<unsigned long>(y)))
      ++_rank.at(static_cast<unsigned long>(x));
  }
}
bool UnionFind::isSame(ll x, ll y) { return find(x) == find(y); }
int main() {
  ios::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  vector<ll> x(n, 0);
  UnionFind uf(n);
  bool isF = false;
  for (int i = 0; i < (int)(m); ++i) {
    if (isF) break;
    ll l, r, d;
    cin >> l >> r >> d;
    --l;
    --r;
    if (uf.isSame(l, r)) {
      isF = x.at(r) != x.at(l) + d;
    } else {
      uf.unite(l, r);
    }
    x.at(r) = x.at(l) + d;
  }
  if (isF)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}
