#include <bits/stdc++.h>
using namespace std;
typedef struct E {
  int to, cost;
} edge;
const int MAX_V = 100100;
const int Inf = 1e9;
vector<vector<edge> > E(MAX_V);
int d[MAX_V];
void dijkstra(int s) {
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      que;
  fill_n(d, MAX_V, Inf);
  d[s] = 0;
  que.push(pair<int, int>(0, s));
  while (!que.empty()) {
    pair<int, int> p = que.top();
    que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int j = 0; j < E[v].size(); j++) {
      edge t = E[v][j];
      if (d[t.to] > d[v] + t.cost) {
        d[t.to] = d[v] + t.cost;
        que.push(pair<int, int>(d[t.to], t.to));
      }
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  bool flag = true;
  long long human[n + 10];
  for (int i = 0; i < n + 10; i++) human[i] = -2147483647;
  for (int i = 0; i < m; i++) {
    int l, r, D;
    cin >> l >> r >> D;
    if (!flag) continue;
    edge e;
    e.to = r;
    e.cost = D;
    E[l].push_back(e);
    if (human[l] == -1 && human[r] == -1) {
      human[l] = human[r] = 1;
    } else {
      dijkstra(l);
      if (d[r] != D) flag = false;
    }
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
