#include <bits/stdc++.h>
using namespace std;
int L[200005], R[200005], D[200005], mark[200005] = {0}, dist[200005];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d %d", &L[i], &R[i], &D[i]);
  }
  for (int i = 0; i < m; i++) {
    if (!mark[L[i]]) {
      dist[L[i]] = 0;
    }
    if (!mark[R[i]])
      dist[R[i]] = dist[L[i]] + D[i];
    else if (mark[L[i]] && mark[R[i]]) {
      int t = dist[R[i]] - dist[L[i]];
      if (t != D[i]) {
        printf("No\n");
        return 0;
      }
    }
    mark[L[i]] = mark[R[i]] = 1;
  }
  printf("Yes\n");
  return 0;
}
