#include <bits/stdc++.h>
using namespace std;
const long long inf = 1LL << 59LL;
long long pos[200005];
struct info {
  int l, r;
  long long d;
} infos[400005];
bool cmp(info a, info b) {
  if (a.l != b.l)
    return a.l < b.l;
  else if (a.l == b.l)
    return a.r < b.r;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= 200005; i++) pos[i] = inf;
  for (int i = 1; i <= m; i++) cin >> infos[i].l >> infos[i].r >> infos[i].d;
  sort(infos + 1, infos + m + 1, cmp);
  for (int i = 1; i <= m; i++) {
    long long l = infos[i].l;
    long long r = infos[i].r;
    long long d = infos[i].d;
    if (pos[l] == inf && pos[r] == inf) {
      pos[l] = l;
      pos[r] = pos[l] + d;
    } else if (pos[l] == inf)
      pos[l] = pos[r] - d;
    else if (pos[r] == inf)
      pos[r] = pos[l] + d;
    else {
      if (pos[l] + d != pos[r] && pos[r] - d != pos[l]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
