#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
const long long MAXN = 1e6 + 7;
const double EPS = 1e-8;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<long long> sz(n);
  vector<long long> num(n);
  vector<long long> d(n, 0);
  vector<vector<long long> > a(n);
  for (long long i = 0; i < n; i++) {
    num[i] = i;
    sz[i] = 1;
    a[i].push_back(i);
  }
  for (long long i = 0; i < m; i++) {
    long long v, u, da;
    cin >> v >> u >> da;
    v--, u--;
    if (num[v] == num[u]) {
      if (d[v] + da != d[u]) {
        cout << "No\n";
        return 0;
      }
      continue;
    }
    if (sz[num[v]] > sz[num[u]]) {
      swap(v, u);
      da = -da;
    }
    long long sh = d[v] + da - d[u];
    long long pred = num[u];
    for (long long x : a[num[u]]) {
      d[x] += sh;
      a[num[v]].push_back(x);
      num[x] = num[v];
    }
    a[pred].clear();
    sz[num[v]] = a[num[v]].size();
  }
  cout << "Yes\n";
  return 0;
}
