#include <bits/stdc++.h>
using namespace std;
int par[100000 + 1], ds[100000 + 1];
void init(int n) {
  for (int i = 1; i <= n; i++) {
    par[i] = i;
    ds[i] = 0;
  }
}
int find(int x) {
  if (par[x] == x) return x;
  ds[x] += ds[par[x]];
  par[x] = find(par[x]);
  return par[x];
}
inline int dist(int l, int r) { return ds[r] - ds[l]; }
bool unite(int _x, int _y, int d) {
  int x = find(_x), y = find(_y);
  if (x == y) {
    if (dist(_x, _y) != d) return false;
  } else {
    par[x] = y;
    ds[y] = d - dist(_x, _y);
  }
  return true;
}
int main() {
  int n, m;
  cin >> n >> m;
  init(n);
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    if (!unite(l, r, d)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
