#include <bits/stdc++.h>
using namespace std;
long long int x[100001] = {};
long long int g[100001] = {};
int main() {
  long long int n, m;
  cin >> n >> m;
  vector<vector<long long int> > v;
  long long int gro = 1;
  for (long long int i = 0; i < m; i++) {
    long long int l, r, d;
    cin >> l >> r >> d;
    if (g[l] == 0) {
      if (g[r] == 0) {
        vector<long long int> vv;
        v.push_back(vv);
        v[gro - 1].push_back(l);
        v[gro - 1].push_back(r);
        x[r] = d;
        g[l] = gro;
        g[r] = gro;
        gro++;
      } else {
        x[l] = x[r] - d;
        g[l] = g[r];
        v[g[r] - 1].push_back(l);
      }
    } else {
      if (g[r] == 0) {
        x[r] = x[l] + d;
        g[r] = g[l];
        v[g[l] - 1].push_back(r);
      } else {
        if (g[l] == g[r]) {
          if (x[r] - x[l] != d) {
            cout << "No" << endl;
            return 0;
          }
        } else {
          long long int p = x[l] + d - x[r];
          for (int j = 0; j < v[g[r] - 1].size(); j++) {
            long long int k = v[g[r] - 1][j];
            g[k] = g[l];
            x[k] += p;
          }
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
