#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  char ch = getchar();
  long long x = 0;
  int op = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') op = -1;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return x * op;
}
inline void write(long long a) {
  if (a < 0) putchar('-'), a = -a;
  if (a >= 10) write(a / 10);
  putchar('0' + a % 10);
}
const int N = 100010;
int n, m;
int fa[N], d[N];
inline int getfa(int x) {
  if (fa[x] == x) return x;
  int tmp = getfa(fa[x]);
  d[x] += d[fa[x]];
  fa[x] = tmp;
  return tmp;
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) fa[i] = i, d[i] = 0;
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read(), z = read(), fx, fy;
    fx = getfa(x), fy = getfa(y);
    if (fx != fy) {
      fa[fy] = fx;
      d[y] = d[x] + z;
    } else {
      if (d[y] - d[x] != z) {
        puts("No");
        return 0;
      }
    }
  }
  puts("Yes");
  return 0;
}
