#include <bits/stdc++.h>
using namespace std;
inline int ri() {
  register int x = 0;
  register bool f = 0;
  register char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = 1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    x = x * 10 + ch - '0';
    ch = getchar();
  };
  return f ? -x : x;
}
void wi(int x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) wi(x / 10);
  putchar('0' + x % 10);
}
const int N = 1e5 + 5, M = 2 * N;
struct data {
  int x1, x2, d;
  bool operator<(const data &t) const {
    return x1 == t.x1 ? x2 < t.x2 : x1 < t.x1;
  }
} q[M];
int fa[N], val[N];
int getf(int x) { return fa[x] == x ? x : fa[x] = getf(fa[x]); }
void gg() {
  puts("No");
  exit(0);
}
int main() {
  int n = ri(), m = ri(), i, x, y;
  for (i = 1; i <= n; i++) fa[i] = i;
  for (i = 1; i <= m; i++) {
    q[i].x1 = ri(), q[i].x2 = ri(), q[i].d = ri();
    if (q[i].x2 < q[i].x1) swap(q[i].x1, q[i].x2), q[i].d = -q[i].d;
  }
  sort(q + 1, q + 1 + m);
  for (i = 1; i <= m; i++) {
    x = getf(q[i].x1), y = getf(q[i].x2);
    if (x == y) {
      if (val[q[i].x2] - val[q[i].x1] == q[i].d)
        continue;
      else
        gg();
    }
    fa[y] = x;
    val[q[i].x2] = val[q[i].x1] + q[i].d;
  }
  puts("Yes");
  return 0;
}
