#include <bits/stdc++.h>
using namespace std;
int pre[100005], rnk[100005];
int F(int x) {
  if (x != pre[x]) {
    int p = pre[x];
    pre[x] = F(pre[x]);
    rnk[x] += rnk[p];
  }
  return pre[x];
}
int main() {
  int n, m;
  int l, r, d;
  while (cin >> n >> m) {
    for (int i = 0; i < 100005; i++) {
      pre[i] = i;
      rnk[i] = 0;
    }
    int f = 0;
    for (int i = 0; i < m; i++) {
      cin >> l >> r >> d;
      int lx = F(l);
      int rx = F(r);
      if (lx != rx) {
        pre[rx] = lx;
        rnk[rx] = rnk[l] - 0 + d;
      } else if (rnk[r] - rnk[l] != d) {
        f = 1;
      }
    }
    string ss[] = {"Yes", "No"};
    cout << ss[f] << endl;
  }
  return 0;
}
