#include <bits/stdc++.h>
using namespace std;
const long long INF = INT_MAX;
const long long MAX_V = 100000;
vector<pair<long long, long long> > G[MAX_V];
long long v, d[MAX_V], r;
void dijk(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, d + v, INF);
  d[s] = 0;
  que.push(pair<long long, long long>(0, s));
  for (; !que.empty();) {
    pair<long long, long long> p = que.top();
    que.pop();
    long long v = p.second;
    if (d[v] < p.first) continue;
    for (long long i = 0; i < (long long)G[v].size(); i++) {
      pair<long long, long long> e = G[v][i];
      if (d[e.first] > d[v] + e.second) {
        if (d[e.first] != INF) r = 1;
        d[e.first] = d[v] + e.second;
        que.push(pair<long long, long long>(d[e.first], e.first));
      }
    }
  }
}
signed main() {
  long long e, top[100000] = {};
  cin >> v >> e;
  for (long long i = 0; i < e; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    if (top[a] == 1 && top[b] == 2) r = 1;
    top[b] = 1;
    if (top[a] != 1) top[a] = 2;
    G[a].push_back(pair<long long, long long>(b, c));
  }
  for (long long i = 0; i < v; i++)
    if (top[i] == 2) dijk(i);
  if (r)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}
