#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> graph(100000);
vector<long long> id(100000, -1);
vector<bool> searched(100000, false);
long long I;
void search(long long n, long long b) {
  if (searched[n]) return;
  searched[n] = true;
  id[n] = I;
  for (long long i = 0; i < graph[n].size(); ++i) search(graph[n][i], 1);
  if (b == 0) ++I;
  return;
}
signed main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> L(M), R(M), D(M);
  for (long long i = 0; i < M; ++i) cin >> L[i] >> R[i] >> D[i];
  vector<long long> x(N);
  vector<bool> y(N, false);
  for (long long i = 0; i < M; ++i) {
    if ((y[L[i] - 1] == false) && (y[R[i] - 1] == false)) {
      x[L[i] - 1] = 0;
      x[R[i] - 1] = D[i];
      y[L[i] - 1] = true;
      y[R[i] - 1] = true;
    }
    if ((y[L[i] - 1] == true) && (y[R[i] - 1] == false)) {
      x[R[i] - 1] = x[L[i] - 1] + D[i];
      y[R[i] - 1] = true;
    }
    if ((y[L[i] - 1] == false) && (y[R[i] - 1] == true)) {
      x[L[i] - 1] = x[R[i] - 1] - D[i];
      y[L[i] - 1] = true;
    }
    if ((y[L[i] - 1] == true) && (y[R[i] - 1] == true)) {
      if (x[R[i] - 1] - x[L[i] - 1] != D[i]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  for (long long i = 0; i < M; ++i) {
    graph[L[i] - 1].push_back(R[i] - 1);
    graph[R[i] - 1].push_back(L[i] - 1);
  }
  I = 0;
  for (long long i = 0; i < N; ++i) search(i, 0);
  vector<vector<long long>> K(I);
  for (long long i = 0; i < N; ++i) K[id[i]].push_back(x[i]);
  for (long long i = 0; i < I; ++i) sort(K[i].begin(), K[i].end());
  long long m = 0;
  for (long long i = 0; i < I; ++i) m = max(m, K[i][K[i].size() - 1] - K[i][0]);
  if (m <= 1000000000)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
