#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int l = 0, f = 1;
  char a = getchar();
  for (; a < '0' || a > '9'; a = getchar())
    if (a == '-') f = -1;
  for (; a >= '0' && a <= '9'; a = getchar()) l = l * 10 + a - 48;
  return l * f;
}
const int N = 100005;
struct Query {
  int l, r, d;
} q[N * 2];
int n, m, d[N];
bool cmp(Query x, Query y) { return x.l == y.l ? x.r < y.r : x.l < y.l; }
int main(int argc, char const *argv[]) {
  n = read(), m = read();
  for (int i = 1; i <= m; ++i)
    q[i].l = read(), q[i].r = read(), q[i].d = read();
  sort(q + 1, q + 1 + m, cmp);
  memset(d, -1, sizeof(d));
  d[q[1].l] = 0;
  for (int i = 1; i <= m; ++i) {
    if (d[q[i].r] == -1)
      d[q[i].r] = d[q[i].l] + q[i].d;
    else if (d[q[i].r] != d[q[i].l] + q[i].d) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}
