#include <bits/stdc++.h>
int K;
int bases[(100000)], offsets[(100000)];
void uf_init(int N) {
  K = N;
  for (int i = 0; i < K; i++) {
    bases[i] = i;
    offsets[i] = 0;
  }
}
int uf_find_root_r(int k, int *p_offset) {
  if (bases[k] == k) {
    *p_offset = 0;
    return k;
  }
  int ret = uf_find_root_r(bases[k], p_offset);
  *p_offset += offsets[k];
  bases[k] = ret;
  offsets[k] = *p_offset;
  return ret;
}
int uf_find_base(int k) {
  int offset;
  return uf_find_root_r(k, &offset);
}
int uf_add(int l, int r, int d) {
  const int base_l = uf_find_base(l), offset_l = offsets[l];
  const int base_r = uf_find_base(r), offset_r = offsets[r];
  if (base_l == base_r) {
    return offset_r - offset_l == d;
  } else if (base_l == l) {
    bases[l] = r;
    offsets[l] = -d;
    return 1;
  } else if (base_r == r) {
    bases[r] = l;
    offsets[r] = d;
    return 1;
  } else {
    bases[base_r] = base_l;
    offsets[base_r] = d + offset_r - offset_l;
    return 1;
  }
}
void uf_print() {
  printf("bases:\n");
  for (int i = 0; i < K; i++) {
    printf("%5d ", bases[i]);
  }
  printf("\noffsets:\n");
  for (int i = 0; i < K; i++) {
    printf("%5d ", offsets[i]);
  }
  printf("\n");
}
int main(int argc, char *argv[]) {
  int N, M, Ls[(200000)], Rs[(200000)], Ds[(200000)];
  scanf("%d %d", &N, &M);
  for (int i = 0; i < M; i++) {
    scanf("%d %d %d", &Ls[i], &Rs[i], &Ds[i]);
    Ls[i]--;
    Rs[i]--;
  }
  uf_init(N);
  int possible = 1;
  for (int i = 0; i < M; i++) {
    if (!uf_add(Ls[i], Rs[i], Ds[i])) {
      possible = 0;
      break;
    }
  }
  if (possible) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}
