#include <bits/stdc++.h>
typedef struct union_find_depth {
  int32_t *parent;
  int32_t *depth;
  int32_t size;
} union_find;
union_find *new_union_find(const int32_t n) {
  union_find *u = ((union_find *)calloc((1), sizeof(union_find)));
  u->parent = ((int32_t *)calloc((n), sizeof(int32_t)));
  u->depth = ((int32_t *)calloc((n), sizeof(int32_t)));
  u->size = n;
  for (int32_t i = 0; i < n; ++i) {
    u->parent[i] = -1;
  }
  return u;
}
int32_t root(union_find *u, int32_t x) {
  while (u->parent[x] >= 0) {
    x = u->parent[x];
  }
  return x;
}
int32_t depth(union_find *u, int32_t x) {
  int32_t sum = 0;
  while (u->parent[x] >= 0) {
    sum += u->depth[x];
    x = u->parent[x];
  }
  return sum;
}
int unite(union_find *u, int32_t x, int32_t y, int32_t w) {
  int32_t rx = root(u, x);
  int32_t ry = root(u, y);
  if (rx == ry) {
    return depth(u, x) + w == depth(u, y);
  }
  if (u->parent[rx] > u->parent[ry]) {
    int32_t swap = rx;
    rx = ry;
    ry = swap;
    w = -w;
  }
  u->depth[ry] = depth(u, x) + w - depth(u, y);
  u->parent[rx] += u->parent[ry];
  u->parent[ry] = rx;
  return 1;
}
void run(void) {
  int32_t n, m;
  scanf("%" SCNi32 "%" SCNi32, &n, &m);
  union_find *u = new_union_find(n + 1);
  while (m--) {
    int32_t l, r, d;
    scanf("%" SCNi32 "%" SCNi32 "%" SCNi32, &l, &r, &d);
    if (!unite(u, l, r, d)) {
      puts("No");
      return;
    }
  }
  puts("Yes");
}
int main(void) {
  run();
  return 0;
}
