#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 29;
const long long longinf = 1LL << 60;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
struct edge {
  int to, cost;
};
int n, m;
vector<edge> G[200001];
int d[100001];
bool ans;
void dijkstra(int s) {
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      q;
  for (int i = 0; i < (int)(n); i++) d[i] = inf;
  d[s] = 0;
  q.push(pair<int, int>(0, s));
  while (!q.empty()) {
    pair<int, int> p = q.top();
    q.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < (int)(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<int, int>(d[e.to], e.to));
      }
    }
  }
}
int main() {
  cin >> n >> m;
  int l[m], r[m], dist[m];
  for (int i = 0; i < (int)(m); i++) {
    cin >> l[i] >> r[i] >> dist[i];
    edge el;
    el.to = r[i] - 1;
    el.cost = dist[i];
    G[l[i] - 1].push_back(el);
    edge e;
    e.to = l[i] - 1;
    e.cost = -dist[i];
    G[r[i] - 1].push_back(e);
  }
  ans = true;
  dijkstra(0);
  for (int i = 0; i < (int)(m); i++) {
    if ((d[r[i] - 1] - d[l[i] - 1]) != dist[i]) ans = false;
  }
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
