#include <bits/stdc++.h>
using namespace std;
long long N, M;
long long val[100005], Min[100005], Max[100005];
long long parent[100005];
void init() {
  for (long long i = 1; i <= N; i++) parent[i] = i;
}
long long root(long long i) {
  if (parent[i] == i) return i;
  return parent[i] = root(parent[i]);
}
void unite(long long i, long long j) {
  long long root_i = root(i), root_j = root(j);
  if (root_i == root_j) return;
  parent[root_i] = root_j;
}
bool same(long long i, long long j) { return root(i) == root(j); }
int main(void) {
  cin >> N >> M;
  init();
  for (long long i = 1; i <= N; i++) val[i] = -2000000000000000005;
  long long l, r, d;
  for (long long m = 0; m < M; m++) {
    cin >> l >> r >> d;
    unite(l, r);
    if (val[l] == -2000000000000000005 && val[r] == -2000000000000000005) {
      val[l] = 0, val[r] = d;
    } else if (val[l] != 2000000000000000005 &&
               val[r] == -2000000000000000005) {
      val[r] = val[l] + d;
    } else if (val[l] == -2000000000000000005 &&
               val[r] != -2000000000000000005) {
      val[l] = val[r] - d;
    } else {
      if (val[l] + d != val[r]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  for (long long i = 1; i <= N; i++)
    if (val[i] == 2000000000000000005) val[i] = 0;
  for (long long i = 1; i <= N; i++) root(i);
  for (long long i = 1; i <= N; i++) {
    Max[i] = -2000000000000000005, Min[i] = 2000000000000000005;
  }
  for (long long i = 1; i <= N; i++) {
    Max[parent[i]] = max(Max[parent[i]], val[i]);
    Min[parent[i]] = min(Min[parent[i]], val[i]);
  }
  for (long long i = 1; i <= N; i++) {
    if (Max[i] - Min[i] > 1000000000) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
