#include <bits/stdc++.h>
using namespace std;
int L[200001];
int R[200001];
int D[200001];
int x[100001] = {-1};
int x_next[100001] = {-1};
int x_prev[100001] = {-1};
bool x_decide[10001] = {false};
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> L[i] >> R[i] >> D[i];
  }
  x[L[0]] = 0;
  x_decide[L[0]] = true;
  x_next[L[0]] = R[0];
  x[R[0]] = D[0];
  x_decide[R[0]] = true;
  x_prev[R[0]] = L[0];
  for (int i = 1; i < M; i++) {
    if (x_decide[L[i]] && x_decide[R[i]]) {
      if (x[R[i]] - x[L[i]] != D[i]) {
        cout << "No" << endl;
        return 0;
      }
    } else if (x_decide[L[i]]) {
      int shift = (x[L[i]] + D[i]) - x[R[i]];
      x[R[i]] = x[L[i]] + D[i];
      x_next[L[i]] = R[i];
      x_prev[R[i]] = L[i];
      x_decide[R[i]] = true;
      int p = x_next[R[i]];
      while (p != 0 && x_decide[p] == false) {
        x[p] += shift;
        p = x_next[p];
      }
      p = x_prev[R[i]];
      while (p != 0 && x_decide[p] == false) {
        x[p] += shift;
        p = x_prev[p];
      }
    } else if (x_decide[R[i]]) {
      int shift = (x[R[i]] - D[i]) - x[L[i]];
      x[L[i]] = x[R[i]] - D[i];
      x_next[L[i]] = R[i];
      x_prev[R[i]] = L[i];
      x_decide[L[i]] = true;
      int p = x_next[L[i]];
      while (p != 0 && x_decide[p] == false) {
        x[p] += shift;
        p = x_next[p];
      }
      p = x_prev[R[i]];
      while (p != 0 && x_decide[p] == false) {
        x[p] += shift;
        p = x_prev[p];
      }
    } else {
      x[L[i]] = 0;
      x_next[L[i]] = R[i];
      x[R[i]] = D[i];
    }
  }
  cout << "Yes" << endl;
}
