#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, k = 1;
  char z = getchar();
  while (z < '0' || z > '9') {
    if (z == '-') k = -1;
    z = getchar();
  }
  while (z >= '0' && z <= '9') {
    x = (x << 3) + (x << 1) + z - 48;
    z = getchar();
  }
  return x * k;
}
const long long N = 100100, M = 200100;
struct xint {
  long long x, y, z;
} p[M];
long long n, m, a[N];
bool ans = 1;
inline bool cmp(xint a, xint b) { return a.x < b.x ? 1 : 0; }
int main() {
  n = read();
  m = read();
  for (long long i = 1; i <= m; ++i)
    p[i].x = read(), p[i].y = read(), p[i].z = read();
  sort(p + 1, p + m + 1, cmp);
  a[p[1].x] = 1;
  for (long long i = 1; i <= m; ++i) {
    long long x = p[i].x, y = p[i].y, z = p[i].z;
    if (x == y) {
      ans = 0;
      break;
    }
    if (a[y] && a[x] + z != a[y]) {
      ans = 0;
      break;
    }
    a[y] = a[x] + z;
  }
  if (ans)
    printf("Yes");
  else
    printf("No");
  return 0;
}
