#include <bits/stdc++.h>
using namespace std;
template <class T, class S>
bool chmax(T &a, const S &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class S>
bool chmin(T &a, const S &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
long long gcd(long long n, long long m) { return (m ? gcd(m, n % m) : n); }
long long lcm(long long n, long long m) { return n / gcd(n, m) * m; }
vector<vector<long long>> check(100010, vector<long long>());
vector<bool> flag(100010);
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  long long n, m;
  cin >> n >> m;
  vector<vector<pair<long long, long long>>> graph(
      n, vector<pair<long long, long long>>());
  vector<long long> l(m), r(m), d(m);
  vector<long long> cnt(n);
  for (long long i = 0; i < (m); i++) {
    cin >> l[i] >> r[i] >> d[i];
    l[i]--;
    r[i]--;
    graph[l[i]].push_back(pair<long long, long long>(r[i], d[i]));
    cnt[r[i]]++;
  }
  vector<long long> dis(n, -1);
  priority_queue<pair<long long, long long>> que;
  for (long long i = 0; i < (n); i++) {
    if (cnt[i] == 0) {
      que.push(pair<long long, long long>(0, i));
      dis[i] = 0;
    }
  }
  while (!que.empty()) {
    pair<long long, long long> p = que.top();
    que.pop();
    long long pf = p.first;
    long long ps = p.second;
    flag[ps] = true;
    for (pair<long long, long long> i : graph[ps]) {
      if (dis[i.first] != -1 && dis[i.first] != dis[ps] + i.second) {
        cout << "No" << '\n';
        return 0;
      } else {
        dis[i.first] = dis[ps] + i.second;
        que.push(pair<long long, long long>(dis[i.first], i.first));
      }
    }
  }
  bool ans = true;
  for (long long i = 0; i < (n); i++)
    if (!flag[i]) ans = false;
  cout << (ans ? "Yes" : "No") << '\n';
}
