#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100003;
struct data {
  long long l, r, d;
} q[MAXN * 2];
int m, n;
long long x[MAXN];
bool cmp(data a, data b) {
  if (a.l != b.l)
    return (a.l < b.l);
  else
    return (a.r < b.r);
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> q[i].l >> q[i].r >> q[i].d;
    if (q[i].l > q[i].r) swap(q[i].l, q[i].r);
  }
  sort(q + 1, q + m + 1, cmp);
  bool kt = 1;
  x[q[1].l] = 1;
  for (int i = 1; i <= m; i++) {
    if (i > 1)
      if (q[i].l == q[i].r)
        if (q[i].d < q[i - 1].d) kt = 0;
    if (x[q[i].l] != 0 && x[q[i].r] != 0) {
      if (x[q[i].r] - x[q[i].l] != q[i].d) kt = 0;
    } else {
      x[q[i].r] = x[q[i].l] + q[i].d;
    }
  }
  if (kt == 0)
    cout << "No";
  else
    cout << "Yes";
  return 0;
}
