#include <bits/stdc++.h>
using namespace std;
namespace my {
inline char cn() {
  static char buf[1000010], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
template <class TY>
void read(TY &x) {
  x = 0;
  int f1 = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f1 = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + (ch - '0'), ch = getchar();
  x *= f1;
}
char OP[1000030], Zhan[30];
int op = 0, Top;
void fcheck(int type = 0) {
  if (type || op >= 1000000) fwrite(OP, 1, op, stdout), op = 0;
}
template <class TY>
inline void write(TY x) {
  if (x == 0) {
    OP[op++] = '0';
    fcheck();
    return;
  }
  Top = 0;
  while (x) Zhan[++Top] = x % 10 + '0', x /= 10;
  while (Top) OP[op++] = Zhan[Top--];
  fcheck();
}
const int maxn = 200010, inf = 1000000007;
int mod = 998244353;
int ksm(int x, int y) {
  int re = 1;
  for (; (y & 1 ? re = 1ll * re * x % mod : 0), y;
       y >>= 1, x = 1ll * x * x % mod)
    ;
  return re;
}
int fac[maxn], inv_fac[maxn], inv[maxn];
void work_math() {
  inv[1] = 1;
  for (int i = 2; i <= maxn - 10; i++)
    inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
  fac[0] = inv_fac[0] = 1;
  for (int i = 1; i <= maxn - 10; i++) fac[i] = 1ll * fac[i - 1] * i % mod;
  inv_fac[maxn - 10] = ksm(fac[maxn - 10], mod - 2);
  for (int i = maxn - 11; i >= 1; i--)
    inv_fac[i] = 1ll * inv_fac[i + 1] * (i + 1) % mod;
}
struct disc {
  int x, y;
};
bool compp(disc x, disc y) { return x.x < y.x; }
void discretization(int *darr, int dn) {
  static disc b[maxn];
  for (int i = 1; i <= dn; i++) b[i].x = darr[i], b[i].y = i;
  sort(b + 1, b + dn + 1, compp);
  static int tot = 0;
  b[0].x = -9666;
  for (int i = 1; i <= dn; i++)
    if (b[i].x != b[i - 1].x)
      darr[b[i].y] = ++tot;
    else
      darr[b[i].y] = tot;
}
template <class TY>
TY gcd(TY x, TY y) {
  return !y ? x : gcd(y, x % y);
}
int n, m;
struct edge {
  int y, next;
} e[maxn << 2];
int first[maxn], len = 0;
void buildroad(int x, int y) {
  e[++len] = (edge){y, first[x]};
  first[x] = len;
}
long long val[maxn];
int f[maxn], size[maxn];
int findfa(int x) { return x == f[x] ? x : f[x] = findfa(f[x]); }
void go(int x, int fa, int z) {
  val[x] += z;
  for (int i = first[x]; i; i = e[i].next)
    if (e[i].y != fa) go(e[i].y, x, z);
}
void main() {
  read(n);
  read(m);
  memset(val, 0, sizeof(val));
  for (int i = 1; i <= n; i++) f[i] = i;
  for (int i = 1, x, y, z; i <= m; i++) {
    read(x);
    read(y);
    read(z);
    if (findfa(x) == findfa(y)) {
      if (val[y] - val[x] != (long long)z) {
        printf("No");
        return;
      }
    } else {
      int xx = findfa(x), yy = findfa(y);
      if (size[xx] < size[yy])
        size[yy] += size[xx], go(x, 0, (val[y] - val[x]) - z), f[xx] = yy;
      else
        size[xx] += size[yy], f[yy] = xx, go(y, 0, z - (val[y] - val[x]));
      buildroad(x, y);
    }
  }
  printf("Yes");
}
}  // namespace my
int main() {
  my::main();
  return 0;
}
