#include <bits/stdc++.h>
const int MAX_N = 100000;
int par[MAX_N];
int rank[MAX_N];
int dist2par[MAX_N];
void init(int n) {
  for (int i = 0; i < n; i++) {
    par[i] = i;
    rank[i] = 0;
    dist2par[i] = 0;
  }
}
int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    int oldpar = par[x];
    int newpar = find(oldpar);
    par[x] = newpar;
    dist2par[x] += dist2par[oldpar];
    return newpar;
  }
}
bool unite(int l, int r, int d) {
  int rl = find(l);
  int dl = dist2par[l];
  int rr = find(r);
  int dr = dist2par[r];
  if (rl == rr) return d == dl - dr;
  if (rank[l] < rank[r]) {
    par[l] = r;
    dist2par[l] = d;
  } else {
    par[r] = l;
    dist2par[r] = -d;
    if (rank[l] == rank[r]) rank[l]++;
  }
  return true;
}
int main() {
  int n, m;
  std::cin >> n >> m;
  init(n);
  bool ok = true;
  for (int i = 0; i < m; i++) {
    int l, r, d;
    std::cin >> l >> r >> d;
    if (ok) {
      ok = unite(l, r, d);
    }
  }
  std::cout << (ok ? "Yes" : "No") << std::endl;
  return 0;
}
