#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
vector<vector<long long> > ed;
vector<vector<long long> > dd;
vector<long long> v;
vector<long long> X;
long long dfs(long long a, long long p) {
  v[a] = 1;
  for (long long i = 0; i < ed[a].size(); i++) {
    if (v[ed[a][i]] == 0) {
      X[ed[a][i]] = X[a] + dd[a][i];
      dfs(ed[a][i], a);
    }
  }
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, M;
  cin >> N >> M;
  vector<long long> L(N);
  vector<long long> R(N);
  vector<long long> D(N);
  ed.resize(N);
  dd.resize(N);
  v.resize(N, 0);
  X.resize(N, 0);
  long long res = 0;
  for (long long i = 0; i < M; i++) {
    cin >> L[i] >> R[i] >> D[i];
    L[i]--;
    R[i]--;
    ed[L[i]].push_back(R[i]);
    dd[L[i]].push_back(D[i]);
    ed[R[i]].push_back(L[i]);
    dd[R[i]].push_back(-D[i]);
  }
  for (long long i = 0; i < N; i++) {
    if (v[i] == 0) {
      X[i] = 0;
      dfs(i, -1);
    }
  }
  bool f = true;
  for (long long i = 0; i < M; i++) {
    if (X[L[i]] + D[i] != X[R[i]]) {
      f = false;
    }
  }
  if (f) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
