#include <bits/stdc++.h>
using namespace std;
long long w, n, m;
long long s, t, v;
long long f[100005], val[100005];
bool flag = 0;
long long find(long long x) {
  if (f[x] == x) return x;
  long long F = find(f[x]);
  val[x] += val[f[x]];
  return f[x] = F;
}
void Union(long long x, long long y, long long w) {
  long long a = find(x), b = find(y);
  if (a != b)
    f[a] = b, val[a] = val[y] - val[x] - w;
  else if (val[y] - val[x] != w)
    flag = 1;
}
int main() {
  scanf("%lld%lld", &n, &m);
  flag = 0;
  for (long long i = 0; i <= n; i++) f[i] = i, val[i] = 0;
  for (long long i = 1; i <= m; i++) {
    scanf("%lld%lld%lld", &s, &t, &v);
    if (s > t) swap(t, s);
    Union(s, t, v);
  }
  printf(flag ? "No\n" : "Yes\n");
  return 0;
}
