#include <bits/stdc++.h>
using namespace std;
struct edge {
  long long to, cost;
  edge() {}
  edge(long long t, long long c) : to(t), cost(c) {}
};
long long n, m;
long long L[100010], R[100010];
long long D[100010];
vector<long long> d(100010);
vector<edge> G[100010];
vector<long long> v;
bool tsort() {
  vector<long long> indeg(n);
  stack<long long> S;
  for (long long i = 0; i < n; i++) {
    for (auto &e : G[i]) {
      indeg[e.to]++;
    }
  }
  for (long long i = 0; i < n; i++) {
    if (indeg[i] == 0) S.push(i);
  }
  while (S.size()) {
    long long u = S.top();
    S.pop();
    v.push_back(u);
    for (auto &e : G[u]) {
      indeg[e.to]--;
      if (indeg[e.to] == 0) S.push(e.to);
    }
  }
  return v.size() == n;
}
void dijkstra(long long s) {
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      que;
  fill(d.begin(), d.end(), 1LL << 60);
  d[s] = 0;
  que.push(pair<long long, long long>(0, s));
  while (!que.empty()) {
    pair<long long, long long> p = que.top();
    que.pop();
    long long v = p.second;
    if (p.first > d[v]) 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;
        que.push(pair<long long, long long>(d[e.to], e.to));
      }
    }
  }
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    cin >> L[i] >> R[i] >> D[i];
    L[i]--, R[i]--;
    G[L[i]].push_back(edge(R[i], D[i]));
  }
  if (!tsort()) {
    cout << "No\n";
    return 0;
  }
  dijkstra(v[0]);
  if (!(0 <= d[v[n - 1]] && d[v[n - 1]] <= 1000000000LL)) {
    cout << "No\n";
    return 0;
  }
  for (long long i = 0; i < m; i++) {
    if (d[R[i]] - d[L[i]] != D[i]) {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}
