#include <bits/stdc++.h>
int main() {
  int n, m;
  static int tr[2][110000];
  int ans;
  scanf("%d%d", &n, &m);
  ans = n;
  for (int i = (0); i < (n); ++i) tr[1][i] = i;
  for (int i = (0); i < (n); ++i) tr[2][i] = 0;
  for (int i = (0); i < (m); ++i) {
    int l, r, d;
    scanf("%d%d%d", &l, &r, &d);
    while (tr[1][l] != tr[1][tr[1][l]]) {
      tr[2][l] += tr[2][tr[1][l]];
      tr[1][l] = tr[1][tr[1][l]];
    }
    while (tr[1][r] != tr[1][tr[1][r]]) {
      tr[2][r] += tr[2][tr[1][r]];
      tr[1][r] = tr[1][tr[1][r]];
    }
    if (tr[1][tr[1][l]] == tr[1][tr[1][r]]) {
      if (tr[2][r] - tr[2][l] != d) --ans;
    } else {
      tr[2][r] += tr[2][l] + d;
      tr[1][r] = tr[1][l];
    }
  }
  printf(ans == n ? "Yes\n" : "No\n");
}
