#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
int pre[maxn];
long long val[maxn];
int Find(int x) {
  if (x == pre[x]) {
    return x;
  } else {
    int tmp = pre[x];
    pre[x] = Find(pre[x]);
    val[x] += val[tmp];
    return pre[x];
  }
}
bool link(int x, int y, long long d) {
  int fx = Find(x);
  int fy = Find(y);
  if (fx == fy) {
    return d == 0;
  }
  pre[fy] = fx;
  val[fy] = d + val[x] - val[y];
  return true;
}
int main() {
  int m, n;
  int L, R;
  long long D;
  bool flag;
  while (cin >> n >> m) {
    flag = true;
    for (int i = 0; i < maxn; i++) pre[i] = i, val[i] = 0;
    for (int i = 0; i < m; i++) {
      scanf("%d%d%lld", &L, &R, &D);
      if (!flag) continue;
      if (!link(L, R, D)) flag = false;
    }
    if (flag)
      printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}
