#include <bits/stdc++.h>
using namespace std;
const int cm = 1 << 17;
char cn[cm], *ci = cn + cm;
inline char getcha() {
  if (ci - cn == cm) {
    fread(cn, 1, cm, stdin);
    ci = cn;
  }
  return *ci++;
}
inline int getint() {
  char C = getcha();
  int A = C - '0';
  while ((C = getcha()) >= '0') A = A * 10 + C - '0';
  return A;
}
int P[100001];
int D[100001];
long long Find(int A) {
  if (P[A] < 0) return A;
  long long k = Find(P[A]);
  int d = k >> 30;
  int p = k & ((1 << 30) - 1);
  D[A] += d;
  P[A] = p;
  return ((long long)D[A] << 30) + p;
}
int main() {
  int N = getint();
  int M = getint();
  for (int i = 1; i <= (N); i++) P[i] = -1;
  int OK = 1;
  for (int i = 0; i < (M); i++) {
    int L = getint();
    int R = getint();
    int d = getint();
    long long k = Find(L);
    int dl = k >> 30;
    int l = k & ((1 << 30) - 1);
    k = Find(R);
    int dr = k >> 30;
    int r = k & ((1 << 30) - 1);
    if (l != r) {
      if (P[l] <= P[r]) {
        P[l] += P[r];
        P[r] = l;
        D[r] = dl + d;
      } else {
        P[r] += P[l];
        P[l] = r;
        D[l] = dr - d;
      }
    } else {
      if (dl + d != dr) {
        OK = 0;
        break;
      }
    }
  }
  if (OK)
    printf("Yes");
  else
    printf("No");
  return 0;
}
