#include <stdio.h>
#include <stdlib.h>

void solv(int n, int m) {
  int **dd, l, r, d;
  int i, j;

  dd = (int **)malloc(sizeof (int *) * n);

  for (i = 0; i < n; i++) {
    dd[i] = malloc(sizeof (int) * n);
    for (j = 0; j < n; j++) {
      dd[i][j] = -1;
    }
  }

  for (i = 0; i < m; i++) {
    scanf("%d %d %d", &l, &r, &d);
    l--;
    r--;
    if ((dd[l][r] != -1 && dd[l][r] != d) || dd[r][l] != -1) {
      puts("No");
      for (i = 0; i < n; i++) { free(dd[i]); }
      return;
    }

    dd[l][r] = d;
    for (j = 0; j < n; j++) {
      if (dd[j][l] != -1) {
        if ((dd[j][r] != -1 && d + dd[j][l]) || dd[r][j] != -1) {
          puts("No");
          for (i = 0; i < n; i++) { free(dd[i]); }
          return;
        }
        dd[j][r] = d + dd[j][l];
      }
    }
  }

  for (i = 0; i < n; i++) { free(dd[i]); }

  puts("Yes");
}

int main(int argc, char **argv) {
  int n, m;

  while (scanf("%d %d", &n, &m) != EOF) {
    solv(n, m);
  }

  return 0;
}
