#include <bits/stdc++.h>
using namespace std;
int f[100500], d[100500];
int n;
int t;
void init() {
  for (int i = 1; i <= t; i++) {
    f[i] = i;
    d[i] = 0;
  }
}
int getf(int x) {
  if (f[x] == x)
    return x;
  else {
    int t = getf(f[x]);
    d[x] += d[f[x]];
    f[x] = t;
    return f[x];
  }
}
int main(void) {
  cin >> t >> n;
  init();
  while (n--) {
    int t1, t2, t3;
    cin >> t1 >> t2 >> t3;
    int f1 = getf(t1);
    int f2 = getf(t2);
    if (f1 == f2) {
      if (d[t1] + t3 != d[t2]) {
        puts("No");
        return 0;
      }
    } else {
      f[t2] = t1;
      d[t2] = t3;
    }
  }
  puts("Yes");
  return 0;
}
