#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct unionfind {
  vector<int> par, rk;
  vector<ll> x, xold;
  unionfind() {}
  unionfind(const int n) {
    par.resize(n);
    rk.resize(n);
    x.resize(n);
    xold.resize(n);
    for (int i = 0; i < n; ++i) par[i] = i;
    fill(rk.begin(), rk.end(), 0);
    for (int i = 0; i < n; ++i) x[i] = ((ll)i + 1ll) * 2000000000ll;
    for (int i = 0; i < n; ++i) xold[i] = ((ll)i + 1ll) * 2000000000ll;
  }
  int find(int k) {
    if (par[k] == k) {
      return k;
    } else {
      if (abs(x[par[k]] - x[k]) > 1000000000ll) {
        xold[k] = x[k];
        x[k] += x[par[k]] - xold[par[k]];
      }
      par[k] = find(par[k]);
      return par[k] = find(par[k]);
    }
  }
  bool unite(int l, int r, ll d) {
    int p = find(l), q = find(r);
    if (p == q) {
      if (x[r] - x[l] != d)
        return false;
      else
        return true;
    }
    if (rk[p] < rk[q]) {
      par[p] = q;
      xold[p] = x[p];
      x[p] = x[q] - d - (x[q] - x[r]) + (x[p] - x[l]);
    } else {
      par[q] = p;
      xold[q] = x[q];
      x[q] = x[p] + d + (x[q] - x[r]) - (x[p] - x[l]);
      if (rk[p] == rk[q]) {
        ++rk[p];
      }
    }
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y); }
};
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  unionfind u(n);
  bool ans = true;
  while (m-- > 0) {
    int l, r;
    ll d;
    scanf("%d %d %lld", &l, &r, &d);
    if (ans) ans = u.unite(--l, --r, d);
  }
  if (ans)
    printf("Yes\n");
  else
    printf("No\n");
}
