#include <bits/stdc++.h>
using namespace std;
long long int n, m, x, y, z, f[100005], d[100005], r[100005];
void go(long long int w) {
  long long int q = w, e = f[q];
  while (e != f[e]) {
    d[q] = max(d[q], d[e]) - min(d[q], d[e]);
    f[q] = f[e];
    e = f[e];
  }
}
void merge() {
  long long int q = f[x], w = f[y];
  if (q == w) return;
  if (r[q] > r[w]) swap(q, w), z = -z;
  f[q] = w;
  d[q] = z;
  r[w] += r[q];
}
int main() {
  scanf("%lld%lld", &n, &m);
  for (int i = 1; i <= n; i++) f[i] = i, r[i] = 1;
  for (int i = 0; i < m; i++) {
    scanf("%lld%lld%lld", &x, &y, &z);
    go(x);
    go(y);
    if (f[x] == f[y]) {
      if (max(d[x], d[y]) - min(d[x], d[y]) != z) {
        cout << "No\n";
        return 0;
      }
    } else
      merge();
  }
  cout << "Yes\n";
  return 0;
}
