#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const int N = 100010;
struct info {
  int pre, d;
} A[N];
void init() {
  for (int i = 0; i < N; ++i) {
    A[i].pre = i;
    A[i].d = 0;
  }
}
inline int Find(int n) {
  if (A[n].pre == n) return n;
  int tpre = A[n].pre;
  A[n].pre = Find(A[n].pre);
  A[n].d += A[tpre].d;
  return A[n].pre;
}
inline int Merge(int a, int b, int c) {
  int fa = Find(a), fb = Find(b);
  if (fa == fb)
    return A[a].d + A[b].d == c;
  else {
    A[fa].pre = fb;
    A[fa].d = (c + A[b].d - A[a].d);
    return 1;
  }
}
int main(void) {
  int n, m, a, b, i;
  while (~scanf("%d%d", &n, &m)) {
    init();
    int flag = 1;
    while (m--) {
      int c;
      scanf("%d%d%d", &a, &b, &c);
      if (flag) flag &= Merge(a, b, c);
    }
    puts(flag ? "Yes" : "No");
  }
  return 0;
}
