#include <bits/stdc++.h>
using namespace std;
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const int W = 0, B = 1;
vector<int> dijkstra(const vector<vector<pair<int, int>>> &g, int s) {
  int n = g.size();
  priority_queue<pair<int, int>> pq;
  vector<int> color(n, W), d(n, INF);
  d[s] = 0;
  pq.push(make_pair(0, s));
  while (!pq.empty()) {
    pair<int, int> f(pq.top());
    pq.pop();
    color[f.second] = B;
    if (d[f.second] < (-1) * f.first) continue;
    for (int i = (0); i < (g[f.second].size()); i++) {
      pair<int, int> v(g[f.second][i]);
      if (color[v.first] != B && d[f.second] + v.second < d[v.first]) {
        d[v.first] = d[f.second] + v.second;
        pq.push(make_pair(d[v.first] * (-1), v.first));
      }
    }
  }
  return d;
}
signed main() {
  int N, M;
  cin >> N >> M;
  vector<vector<pair<int, int>>> adj(N, vector<pair<int, int>>());
  vector<int> l(M), r(M), d(M);
  for (int i = (0); i < (M); i++) {
    cin >> l[i] >> r[i] >> d[i];
    l[i]--, r[i]--;
    adj[l[i]].push_back(make_pair(r[i], d[i]));
    adj[r[i]].push_back(make_pair(l[i], -d[i]));
  }
  auto x = dijkstra(adj, 0);
  ;
  for (int i = (0); i < (M); i++) {
    int a = x[l[i]], b = x[r[i]];
    ;
    ;
    if (b - a != d[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
