// https://atcoder.jp/contests/arc090/tasks/arc090_b
#include <stdio.h>

int dd[100001][100001], l[200001], r[200001], d[200001];;

void solv(int n, int m) {
  int i, j;

  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      dd[i][j] = -1;
    }
  }

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

    dd[l[i]][r[i]] = d[i];
    for (j = 1; j <= n; j++) {
      // printf("j = %d, l[i] = %d, dd[j][l[i]] = %d\n", j, l[i], dd[j][l[i]]);
      if (dd[j][l[i]] != -1) {
        if ((dd[j][r[i]] != -1 && d[i] + dd[j][l[i]]) || dd[r[i]][j] != -1) {
          puts("No");
          return;
        }
        dd[j][r[i]] = d[i] + dd[j][l[i]];
        // printf(" set: %d => %d === %d\n", j, r[i], d[i] + dd[j][l[i]]);
      }
    }
  }

  puts("Yes");
}

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

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

  return 0;
}
