#include <bits/stdc++.h>
using namespace std;
const long long INF = 100000000000000001;
int pa[100001] = {};
int ra[100001] = {};
long long d[100001] = {};
int find(int xx) {
  if (pa[xx] == xx) return xx;
  return pa[xx] = find(pa[xx]);
}
bool same(int xx, int yy) { return find(xx) == find(yy); }
long long calc(int xx, int yy) {
  int xpa = find(xx);
  long long d1 = 0;
  while (xx != xpa) {
    d1 += d[xx];
    xx = pa[xx];
  }
  long long d2 = 0;
  while (yy != xpa) {
    d2 += d[yy];
    yy = pa[yy];
  }
  return d2 - d1;
}
void unite(int xx, int yy, long long d1) {
  long long dx = calc(xx, find(xx));
  long long dy = calc(yy, find(yy));
  xx = find(xx);
  yy = find(yy);
  if (ra[xx] < ra[yy]) {
    pa[xx] = yy;
    d[xx] = dx - dy - d1;
  } else {
    pa[yy] = xx;
    d[yy] = dy - dx + d1;
    if (ra[xx] == ra[yy]) ra[xx]++;
  }
  return;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i < n + 1; ++i) pa[i] = i;
  for (int i = 0; i < m; ++i) {
    int l1, r1;
    long long d1;
    cin >> l1 >> r1 >> d1;
    if (!same(l1, r1)) {
      unite(l1, r1, d1);
    } else {
      if (calc(l1, r1) != d1) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  long long ma = 0;
  long long mi = 0;
  for (int i = 1; i < n + 1; ++i) {
    long long xi = calc(i, find(i));
    ma = max(ma, xi);
    mi = min(mi, xi);
  }
  if (ma - mi <= 1000000000) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
