#include <bits/stdc++.h>
using namespace std;
int n, m;
int l[210000], r[210000], d[210000];
vector<pair<int, int> > G[210000];
int dist[210000];
bool used[210000];
void nuri(int now) {
  dist[now] = 0;
  used[now] = 1;
  queue<int> bfs;
  while (!bfs.empty()) bfs.pop();
  bfs.push(now);
  while (!bfs.empty()) {
    int z = bfs.front();
    bfs.pop();
    cout << z << endl;
    for (int i = 0; i < G[z].size(); i++) {
      int next = G[z][i].first;
      if (!used[next]) {
        used[next] = 1;
        dist[next] = dist[z] + G[z][i].second;
        bfs.push(next);
      }
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> l[i] >> r[i] >> d[i];
    l[i]--;
    r[i]--;
    G[l[i]].push_back(make_pair(r[i], d[i]));
    G[r[i]].push_back(make_pair(l[i], -d[i]));
  }
  for (int i = 0; i < n; i++) {
    if (!used[i]) nuri(i);
  }
  bool ok = 1;
  for (int i = 0; i < m; i++) {
    if (dist[r[i]] - dist[l[i]] != d[i]) ok = 0;
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
