#include <bits/stdc++.h>
using namespace std;
long long dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
long long dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
long long N, M;
long long L[200000], R[200000], D[200000];
long long x[100000];
long long par[100000];
long long rnk[100000];
long long diff[100000];
void init(long long n) {
  for (long long i = 0; i < n; i++) {
    par[i] = i;
    rnk[i] = 0;
  }
}
long long depth(long long x) {
  if (par[x] == x) {
    return 0;
  } else {
    return depth(par[x]) + diff[x];
  }
}
long long find(long long x) {
  if (par[x] == x) {
    return x;
  } else {
    return find(par[x]);
  }
}
void unite(long long x, long long y, long long D) {
  long long dep_x = depth(x);
  long long dep_y = depth(y);
  x = find(x);
  y = find(y);
  if (x == y) {
    return;
  }
  if (rnk[x] < rnk[y]) {
    par[x] = y;
    diff[x] = dep_y - D - dep_x;
  } else {
    par[y] = x;
    diff[y] = dep_x + D - dep_y;
    if (rnk[x] == rnk[y]) {
      rnk[x]++;
    }
  }
}
signed main() {
  cin >> N >> M;
  init(N);
  for (long long i = 0; i < M; i++) {
    cin >> L[i] >> R[i] >> D[i];
    unite(L[i], R[i], D[i]);
  }
  for (long long i = 0; i < M; i++) {
    if (depth(R[i]) - depth(L[i]) != D[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
