#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, m, l, r, dis, fa[maxn], d[maxn];
inline int get(int x, int ans = 0) {
  if (x == fa[x]) return d[x];
  return d[x] + get(fa[x]);
}
inline int find(int x) {
  if (x == fa[x]) return x;
  int root = find(fa[x]);
  d[x] += d[fa[x]];
  return fa[x] = root;
}
int main() {
  for (register int i = 0; i < maxn; ++i) fa[i] = i;
  scanf("%d%d", &n, &m);
  for (register int i = 1; i <= m; ++i) {
    scanf("%d%d%d", &l, &r, &dis);
    int a = find(l), b = find(r);
    if (a != b)
      fa[a] = b, d[a] = get(b) + dis;
    else if (get(l) - dis != get(r))
      return puts("No"), 0;
  }
  return puts("Yes"), 0;
}
