#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9;
const long long INF = 1e18;
long long q[200002][3], ran[100002];
pair<long long, long long> p[100002];
pair<long long, long long> find(long long x, long long y) {
  if (p[x].first == x)
    return pair<long long, long long>(x, y);
  else {
    p[x] = find(p[x].first, p[x].second);
    return pair<long long, long long>(p[x].first, p[x].second + y);
  }
}
bool unite(long long xx, long long yy, long long d) {
  pair<long long, long long> x = find(xx, 0);
  pair<long long, long long> y = find(yy, 0);
  if (x.first == y.first) {
    if (x.second + d == y.second)
      return 0;
    else
      return 1;
  }
  if (ran[x.first] < ran[y.first]) {
    p[x.first] = pair<long long, long long>(y.first, y.second - d);
  } else {
    p[y.first] = pair<long long, long long>(x.first, x.second + d);
    if (ran[x.first] == ran[y.first]) ran[x.first]++;
  }
  return 0;
}
bool same(long long x, long long y) {
  return find(x, 0).first == find(y, 0).first;
}
signed main() {
  long long n, m;
  scanf("%lld%lld", &n, &m);
  for (long long i = 0; i < m; i++)
    for (long long j = 0; j < 3; j++) scanf("%lld", &q[i][j]);
  for (long long i = 0; i < n; i++) {
    p[i].first = i;
    ran[i] = 0;
  }
  for (long long i = 0; i < m; i++) {
    long long l = q[i][0], r = q[i][1], d = q[i][2];
    if (unite(l, r, d)) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}
