#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long par[100005];
long long dis[100005];
long long find(long long x) {
  if (par[x] == x) return x;
  long long p = par[x];
  par[x] = find(par[x]), dis[x] += dis[p];
  return par[x];
}
bool unite(long long x, long long y, long long z) {
  long long px = find(x), py = find(y);
  if (px == py) return dis[x] - dis[y] == z;
  par[px] = py, dis[px] = z;
  return true;
}
signed main() {
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= n; i++) par[i] = i;
  long long l, r, d;
  for (long long i = 1; i <= m; i++) {
    scanf("%lld%lld%lld", &l, &r, &d);
    if (!unite(l, r, d)) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
}
