#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n, m;
  cin >> n >> m;
  vector<pair<ll, ll>> v[n];
  for (ll i = 0; i < m; i++) {
    ll l, r, d;
    cin >> l >> r >> d;
    if (l > r) {
      ll tmp = l;
      l = r;
      r = tmp;
      d *= -1;
    }
    v[l - 1].push_back(pair<ll, ll>(r - 1, d));
  }
  map<ll, ll> ma;
  ma[0] = 0;
  set<ll> s;
  for (ll i = 0; i < n; i++) s.insert(i);
  stack<ll> st;
  st.push(0);
  while (s.size()) {
    ll i;
    if (st.size()) {
      i = st.top();
      st.pop();
    } else {
      i = *s.begin();
    }
    s.erase(s.find(i));
    if (ma.find(i) == ma.end()) {
      ma[i] = 0;
    }
    ll koko = ma[i];
    for (auto info : v[i]) {
      ll po = koko + info.second;
      if (s.find(info.first) != s.end()) {
        st.push(info.first);
      }
      auto ite = ma.find(info.first);
      if (ite == ma.end()) {
        ma[info.first] = po;
      } else {
        if (po != ite->second) {
          cout << "No\n";
          return 0;
        }
      }
    }
  }
  cout << "Yes\n";
  return 0;
}
