#include <bits/stdc++.h>
using namespace std;
struct lrd {
  int l, r, d;
};
bool comp(const lrd& a, const lrd& b) { return a.l < b.l; }
int main() {
  int n, a[100005], m;
  lrd x[200005];
  cin >> n >> m;
  for (int i = 0; i <= n; i++) a[i] = -1;
  for (int i = 0; i < m; i++) {
    cin >> x[i].l >> x[i].r >> x[i].d;
  }
  sort(x, x + m, comp);
  a[x[0].l] = 0;
  for (int i = 0; i < m; i++) {
    if (a[x[i].l] == -1 && a[x[i].r] == -1)
      continue;
    else if (a[x[i].l] != -1 && a[x[i].r] != -1) {
      if (a[x[i].r] - a[x[i].l] != x[i].d) {
        cout << "No" << endl;
        return 0;
      }
    } else if (a[x[i].l] != -1 && a[x[i].r] == -1) {
      a[x[i].r] = a[x[i].l] + x[i].d;
    } else {
      a[x[i].l] = a[x[i].r] - x[i].d;
    }
  }
  for (int i = 0; i < m; i++) {
    if (a[x[i].l] == -1 && a[x[i].r] == -1)
      continue;
    else if (a[x[i].l] != -1 && a[x[i].r] != -1) {
      if (a[x[i].r] - a[x[i].l] != x[i].d) {
        cout << "No" << endl;
        return 0;
      }
    } else if (a[x[i].l] != -1 && a[x[i].r] == -1) {
      a[x[i].r] = a[x[i].l] + x[i].d;
    } else {
      a[x[i].l] = a[x[i].r] - x[i].d;
    }
  }
  cout << "Yes";
  return 0;
}
