#include <bits/stdc++.h>
using namespace std;
__attribute__((constructor)) void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
vector<long long> v[100001];
long long c[100001], s[100001];
map<long long, map<long long, long long> > mp;
void solve(long long p, long long cost) {
  if (s[p] && c[p] != cost) {
    cout << "No" << endl;
    exit(1);
  }
  if (s[p]) return;
  s[p] = 1;
  c[p] = cost;
  for (long long i = (0); i < (v[p].size()); i++) {
    solve(v[p][i], cost + mp[p][v[p][i]]);
  }
}
signed main() {
  long long n, m;
  cin >> n >> m;
  for (long long i = (0); i < (m); i++) {
    long long l, r, d;
    cin >> l >> r >> d;
    v[l].push_back(r);
    v[r].push_back(l);
    mp[l][r] = d;
    mp[r][l] = -d;
  }
  for (long long i = (0); i < (n); i++) {
    if (!s[i]) solve(i, 0);
  }
  cout << "Yes" << endl;
}
