#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 100 * 1000 + 123;
long long n, m, f[MAXN], deg[MAXN];
bool mark[MAXN];
vector<pair<long long, long long> > g[MAXN];
void dfs(long long);
int32_t main() {
  memset(f, 15, sizeof f);
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long l, r, d;
    cin >> l >> r >> d;
    if (d) deg[--r]++;
    g[--l].push_back({r, d});
  }
  for (long long i = 0; i < n; i++)
    if (!mark[i] && !deg[i]) dfs(i);
  for (long long i = 0; i < n; i++)
    for (auto ss : g[i]) {
      long long u, x;
      tie(u, x) = ss;
      if (f[u] != f[i] + x) return cout << "No", 0;
    }
  cout << "Yes";
  return 0;
}
void dfs(long long v) {
  mark[v] = true;
  for (auto ss : g[v]) {
    long long u, q;
    tie(u, q) = ss;
    if (mark[u])
      f[v] = f[u] - q;
    else {
      f[u] = f[v] + q;
      dfs(u);
    }
  }
}
