#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]));
  }
  function<void(long long)> dfs = [&](long long u) {
    vis[u] = true;
    for (auto& i : adj[u]) {
      long long v = i.first, w = i.second;
      if (!vis[v]) {
        x[v] = x[u] + w;
        dfs(v);
      } else if (x[v] != x[u] + w) {
        cout << "No";
        exit(0);
      }
    }
  };
  for (long long i = 1; i <= n; i++) {
    if (!vis[i]) {
      dfs(i);
    }
  }
  cout << "Yes";
}
