#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 6;
long long n, m, r[N], l[N], w[N], x[N], vis[N], ans = 1;
vector<pair<long long, long long> > adj[N];
signed main() {
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    cin >> l[i] >> r[i] >> w[i];
    adj[l[i]].push_back(make_pair(r[i], w[i]));
    adj[r[i]].push_back(make_pair(l[i], -w[i]));
  }
  for (long long i = 1; i <= n; i++) {
    if (!vis[i]) {
      vis[i] = 1;
      queue<long long> q;
      x[i] = 0;
      q.push(i);
      vis[i] = 1;
      while (!q.empty()) {
        long long d = q.front();
        q.pop();
        for (long long j = 0; j < (long long)adj[d].size(); j++) {
          long long v = adj[d][j].first, t = adj[d][j].second;
          if (!vis[v]) {
            vis[v] = 1;
            x[v] = x[d] + t;
            q.push(v);
          } else if (x[v] != x[d] + t) {
            cout << "No";
            return 0;
          }
        }
      }
    }
  }
  cout << "Yes";
}
