#include <bits/stdc++.h>
int main() {
  int N, M;
  scanf("%d %d", &N, &M);
  int *x = new int[N + 1];
  int **a = new int *[M];
  for (int i = 0; i < M; i++) {
    a[i] = new int[3];
  }
  for (int i = 0; i < N + 1; i++) {
    x[i] = -100000;
  }
  for (int i = 0; i < M; i++) {
    for (int j = 0; j < 3; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  bool doesMakeSense = true;
  for (int i = 0; i < M; i++) {
    if (x[a[i][0]] == -100000 && x[a[i][1]] == -100000) {
      x[a[i][0]] = 0;
      x[a[i][1]] = a[i][2];
    } else if (x[a[i][0]] == -100000) {
      x[a[i][0]] = x[a[i][1]] - a[i][2];
    } else if (x[a[i][1]] == -100000) {
      x[a[i][1]] = a[i][2] + x[a[i][0]];
    } else {
      if (x[a[i][1]] - x[a[i][0]] != a[i][2]) {
        doesMakeSense = false;
        break;
      }
    }
  }
  if (doesMakeSense) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  delete[] x;
  x = 0;
  for (int i = 0; i < M; i++) {
    delete[] a[i];
    a[i] = 0;
  }
  delete[] a;
  a = 0;
  return 0;
}
