#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long l[200000], r[200000], d[200000];
vector<long long> et[100000];
vector<long long> ec[100000];
bool used[100000];
long long cst[100000];
signed main() {
  long long i;
  scanf("%lld%lld", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%lld%lld%lld", l + i, r + i, d + i);
    l[i]--;
    r[i]--;
    et[l[i]].push_back(r[i]);
    ec[l[i]].push_back(d[i]);
    et[r[i]].push_back(l[i]);
    ec[r[i]].push_back(-d[i]);
  }
  static queue<long long> que;
  for (i = 0; i < n; i++) {
    if (used[i]) continue;
    used[i] = true;
    que.push(i);
    while (!que.empty()) {
      long long v = que.front();
      que.pop();
      for (i = 0; i < et[v].size(); i++) {
        long long nv = et[v][i];
        if (!used[nv]) {
          used[nv] = true;
          que.push(nv);
          cst[nv] = cst[v] + ec[v][i];
        }
      }
    }
  }
  for (i = 0; i < m; i++) {
    if (cst[r[i]] - cst[l[i]] != d[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
