#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int N, M;
int L, R;
ll D;
int pre[100000 + 10];
int rk[100000 + 10];
ll dist[100000 + 10];
ll dmax[100000 + 10];
ll dmin[100000 + 10];
int cfind(const int xx) {
  int x = xx;
  ll sum = 0;
  if (pre[x] != x) {
    sum += dist[x];
    x = pre[x];
  }
  dist[xx] = sum;
  return pre[x];
}
ll cdist(const int x) {
  cfind(x);
  return dist[x];
}
void cunion(const int a, const int b, const ll d) {
  const int h1 = cfind(a);
  const int h2 = cfind(b);
  const ll d1 = cdist(h1);
  const ll d2 = cdist(h2);
  const ll dd = d + d1 - d2;
  if (rk[h1] < rk[h2]) {
    pre[h1] = h2;
    dist[h1] = -dd;
  } else if (rk[h1] > rk[h2]) {
    pre[h2] = h1;
    dist[h2] = dd;
  } else {
    pre[h1] = h2;
    dist[h1] = -dd;
    rk[h2]++;
  }
}
bool sol() {
  cin >> N >> M;
  fill(dmax, dmax + N + 1, LLONG_MIN);
  fill(dmin, dmin + N + 1, LLONG_MAX);
  iota(pre, pre + N + 1, 0);
  for (int i = 0; i < M; ++i) {
    cin >> L >> R >> D;
    if (L > N || R > N) return false;
    int h1 = cfind(L);
    int h2 = cfind(R);
    if (h1 == h2) {
      if (cdist(R) - cdist(L) != D) return false;
    } else {
      cunion(L, R, D);
    }
  }
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  if (sol())
    cout << "Yes";
  else
    cout << "No";
}
