#include <bits/stdc++.h>
using namespace std;
int n, m;
int fa[100000 + 5], val[100000 + 5];
int find_fa(int x) {
  if (fa[x] == x) return x;
  val[x] += val[fa[x]];
  return find_fa(fa[x]);
}
void unin(int x, int y, int va) {
  int fx = find_fa(x), fy = find_fa(y);
  fa[fx] = fy;
  val[fx] += va - val[x];
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) fa[i] = i;
  int l, r, va;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &l, &r, &va);
    int fl = find_fa(l), fr = find_fa(r);
    if (fl == fr) {
      int t = val[r] - val[l];
      if (t != va) {
        printf("No\n");
        return 0;
      }
    } else
      unin(l, r, -va);
  }
  printf("Yes");
}
