#include <bits/stdc++.h>
using namespace std;
struct edge {
  long long to, cost;
};
vector<edge> G[100005];
long long l[100005], r[100005], c[100005];
long long d[100005];
void dijk(long long s) {
  fill(d, d + 100005, 1 << 30);
  d[s] = 0;
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      Q;
  Q.push(pair<long long, long long>(0, s));
  while (Q.size()) {
    pair<long long, long long> p = Q.top();
    Q.pop();
    long long v = p.second;
    if (d[v] < p.first) continue;
    for (long long i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        Q.push(pair<long long, long long>(d[e.to], e.to));
      }
    }
  }
}
signed main() {
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    cin >> l[i] >> r[i] >> c[i];
    G[l[i]].push_back({r[i], c[i]});
  }
  G[0].push_back({l[0], 0});
  dijk(0);
  for (long long i = 0; i < m; i++) {
    long long L = l[i], R = r[i], C = c[i];
    if (d[R] - d[L] != C) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
}
