#include <bits/stdc++.h>
using namespace std;
int par[100000 + 1], ff_rank[100000 + 1];
long ds[100000 + 1];
void init(int n) {
  for (int i = 1; i <= n; i++) {
    par[i] = i;
    ff_rank[i] = 0;
    ds[i] = 0;
  }
}
int find(int x) {
  if (par[x] == x) return x;
  return par[x] = find(par[x]);
}
void unite(int _x, int _y, int d) {
  int x = find(_x);
  int y = find(_y);
  ds[_y] = ds[_x] + d;
  if (x == y) return;
  if (ff_rank[x] < ff_rank[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (ff_rank[x] == ff_rank[y]) ff_rank[x]++;
  }
}
bool same(int x, int y) { return find(x) == find(y); }
int distance(int l, int r) { return ds[r] - ds[l]; }
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 (same(l, r)) {
      if (distance(l, r) != d) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      unite(l, r, d);
    }
  }
  cout << "Yes" << endl;
  return 0;
}
