#include <bits/stdc++.h>
using namespace std;
int pre[100005];
int dis[100005];
int n, m, l, r, d, fl, fr;
void init() {
  for (int i = 1; i <= n; i++) pre[i] = i, dis[i] = 0;
}
int Find(int x) { return pre[x] == x ? x : pre[x] = Find(pre[x]); }
int same(int l, int r) {
  fl = Find(l);
  fr = Find(r);
  if (fl == fr)
    return 1;
  else
    return 0;
}
void unite() {
  pre[fr] = fl;
  dis[r] = dis[l] + d;
}
int main() {
  cin >> n >> m;
  init();
  int flag = 0;
  while (m--) {
    cin >> l >> r >> d;
    if (flag) continue;
    if (!same(l, r)) {
      unite();
    } else {
      if (dis[r] - dis[l] != d) flag = 1;
    }
  }
  if (flag)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}
