#include <bits/stdc++.h>
typedef struct Human {
  int origin;
  int dis;
} Human;
void koushin(Human h[], int i);
int main() {
  int x[100];
  int N, M;
  int i;
  int ret = 0;
  scanf("%d %d", &N, &M);
  Human human[N];
  for (i = 0; i < N + 1; i++) {
    human[i].origin = i;
    human[i].dis = 0;
  }
  int L[M], R[M], D[M];
  for (i = 0; i < M; i++) {
    scanf("%d %d %d", &L[i], &R[i], &D[i]);
  }
  for (i = 0; i < M; i++) {
    koushin(human, R[i]);
    if (human[L[i]].origin == human[R[i]].origin) {
      if (human[R[i]].dis != D[i]) {
        printf("No\n");
        return 0;
      }
    } else {
      human[R[i]].origin = human[L[i]].origin;
      human[R[i]].dis += human[L[i]].dis + D[i];
    }
  }
  printf("Yes\n");
  return 0;
}
void koushin(Human h[], int i) {
  if (h[i].origin != i) {
    h[i].dis += h[h[i].origin].dis;
    h[i].origin = h[h[i].origin].origin;
  }
}
