#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  int tmp;
  bool ans = true;
  long long L[200005], R[200005], D[200005], x[100005];
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> L[i] >> R[i] >> D[i];
  }
  for (int i = 1; i <= N; i++) {
    x[i] = -2000000;
  }
  for (int i = 0; i < M; i++) {
    if (x[L[i]] == -2000000 && x[R[i]] == -2000000) {
      if (tmp == 0) {
        x[L[i]] = 0;
        tmp += 1;
      }
    }
    if (x[L[i]] != -2000000 && x[R[i]] != -2000000) {
      if (x[R[i]] - x[L[i]] != D[i]) {
        ans = false;
        break;
      }
    } else if (x[L[i]] == -2000000 && x[R[i]] != -2000000) {
      x[L[i]] = x[R[i]] - D[i];
    } else if (x[L[i]] != -2000000 && x[R[i]] == -2000000) {
      x[R[i]] = x[L[i]] + D[i];
    }
  }
  if (ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
