#include <bits/stdc++.h>
using namespace std;
const double pi =
    3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod = 1000000007;
struct edge {
  int to, cost;
};
int main() {
  int n, m, l, r, d;
  vector<vector<edge> > g;
  g.reserve(101010);
  int b[101010] = {};
  cin >> n >> m;
  for (int i = (0); i <= (n); ++i) {
    b[i] = -1;
  }
  for (int i = (0); i < (m); ++i) {
    cin >> l >> r >> d;
    edge ee;
    ee.to = r;
    ee.cost = d;
    g[l].push_back(ee);
    ee.to = l;
    ee.cost = -d;
    g[r].push_back(ee);
  }
  for (int i = (1); i <= (n); ++i) {
    if (b[i] == -1) b[i] = mod;
    for (auto itr = g[i].begin() - g[i].begin();
         itr != g[i].end() - g[i].begin(); ++itr) {
      if (b[g[i][itr].to] != -1 && b[g[i][itr].to] != b[i] + g[i][itr].cost) {
        cout << i << " " << itr << endl;
        cout << "No" << endl;
        return 0;
      }
      b[g[i][itr].to] = b[i] + g[i][itr].cost;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
