#include <bits/stdc++.h>
using namespace std;
long long int n, m, p[100010], chk[100010];
struct JK {
  long long int l, r, d;
} a[200020];
bool cmp(JK x, JK y) {
  if (x.l == y.l) return x.r < y.r;
  return x.l < y.l;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i].l >> a[i].r >> a[i].d;
  }
  sort(a, a + m, cmp);
  for (int i = 0; i < m; i++) {
    if (!chk[a[i].l] and !chk[a[i].r]) {
      p[a[i].l] = 0;
      p[a[i].r] = a[i].d;
      chk[a[i].l] = chk[a[i].r] = 1;
      continue;
    }
    if (chk[a[i].l] and chk[a[i].r]) {
      if (p[a[i].r] - p[a[i].l] != a[i].d) return cout << "No\n", 0;
      continue;
    }
    if (chk[a[i].l]) {
      chk[a[i].r] = 1;
      p[a[i].r] = p[a[i].l] + a[i].d;
      continue;
    }
    if (chk[a[i].r]) {
      chk[a[i].l] = 1;
      p[a[i].l] = p[a[i].r] - a[i].d;
      continue;
    }
  }
  cout << "Yes\n";
}
