#include <bits/stdc++.h>
using namespace std;
void qmax(int &x, int y) {
  if (x < y) x = y;
}
void qmin(int &x, int y) {
  if (x > y) x = y;
}
int read() {
  char s;
  int k = 0, base = 1;
  while ((s = getchar()) != '-' && s != EOF && !(isdigit(s)))
    ;
  if (s == EOF) exit(0);
  if (s == '-') base = -1, s = getchar();
  while (isdigit(s)) {
    k = k * 10 + (s ^ '0');
    s = getchar();
  }
  return k * base;
}
void write(int x) {
  if (x < 0) {
    putchar('-');
    write(-x);
  } else {
    if (x / 10) write(x / 10);
    putchar(x % 10 + '0');
  }
}
int n, m;
int fa[100100];
long long dis[100100];
long long l, r, d, D, X, Y;
int gf(int x) {
  if (fa[x] == x) return x;
  int ft = fa[x];
  fa[x] = gf(fa[x]);
  dis[x] += dis[ft];
  return fa[x];
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1; i <= m; i++) {
    l = read();
    r = read();
    d = read();
    if (gf(l) == gf(r)) {
      D = dis[r] - dis[l];
      if (d != D) {
        printf("No");
        return 0;
      }
    } else {
      X = d + dis[l];
      Y = dis[r];
      if (X >= Y) {
        dis[gf(r)] = X - Y;
        fa[gf(r)] = gf(l);
      } else {
        dis[gf(l)] = Y - X;
        fa[gf(l)] = gf(r);
      }
    }
  }
  printf("Yes");
  return 0;
}
