#include <bits/stdc++.h>
using namespace std;
struct S {
  int x, y, d;
} s[100005];
int n, m;
int a[100005];
int ok = 1;
bool cmp(S aa, S bb) { return aa.x < bb.x; }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &s[i].x, &s[i].y, &s[i].d);
    if (s[i].x > s[i].y) {
      swap(s[i].x, s[i].y);
      s[i].d = -s[i].d;
    }
  }
  sort(s, s + m, cmp);
  memset(a, 127, sizeof(a));
  for (int i = 0; i < m; i++) {
    if (a[s[i].x] > (1 << 30)) {
      a[s[i].x] = 0;
    }
    if (a[s[i].y] < (1 << 30) && a[s[i].y] != a[s[i].x] + s[i].d) {
      ok = 0;
      break;
    }
    a[s[i].y] = a[s[i].x] + s[i].d;
  }
  if (ok)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}
