#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long n, m, d[100010];
bool viz[100010];
vector<pair<long long, long long> > g[100010];
bool dfs(long long nod) {
  viz[nod] = 1;
  for (pair<long long, long long> i : g[nod]) {
    if (viz[i.first] == 0) {
      d[i.first] = d[nod] + i.second;
      dfs(i.first);
    } else {
      if (d[nod] + i.second != d[i.first]) return 0;
    }
  }
  return 1;
}
int32_t main() {
  ios_base ::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    long long l, r, first;
    cin >> l >> r >> first;
    g[l].push_back({r, first});
    g[r].push_back({l, -first});
  }
  for (long long i = 1; i <= n; i++) {
    if (viz[i] == 0 && dfs(i) == 0) return cout << "No", 0;
  }
  cout << "Yes";
}
