#include <bits/stdc++.h>
using namespace std;
long long INF = 1e18;
signed main() {
  ios_base::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  long long v[m][3];
  vector<set<long long> > ms(n);
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j < 3; j++) cin >> v[i][j];
    for (long long j = 0; j < 2; j++) v[i][j]--;
    ms[v[i][0]].insert(i);
    ms[v[i][1]].insert(i);
  }
  vector<long long> ans(n);
  fill(ans.begin(), ans.end(), INF);
  queue<long long> k;
  k.push(0);
  ans[0] = 0;
  while (!k.empty()) {
    long long V = k.front();
    k.pop();
    for (set<long long>::iterator it = ms[V].begin(); it != ms[V].end(); it++) {
      long long S = *it;
      if (v[S][0] == V) {
        long long Q = v[S][1];
        if (ans[Q] != INF) continue;
        ans[Q] = ans[V] + v[S][2];
        k.push(Q);
      } else {
        long long Q = v[S][0];
        if (ans[Q] != INF) continue;
        ans[Q] = ans[V] - v[S][2];
        k.push(Q);
      }
    }
  }
  for (long long i = 0; i < m; i++) {
    long long A = v[i][0];
    long long B = v[i][1];
    long long C = v[i][2];
    if (ans[B] - ans[A] != C) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
