#include <bits/stdc++.h>
using namespace ::std;
int d = -1;
vector<vector<int>> root;
bool is_root(int N, int L, int R, int D) {
  int l = L, r = R;
  d = -1;
  if (root[r - 1][l - 1] > -1) d = 0;
  if (root[l - 1][r - 1] > -1) d = root[l - 1][r - 1];
  root[l - 1][r - 1] = D;
  for (int i = 0; i < N; i++) {
    if (root[i][l - 1] > -1) {
      root[i][r - 1] = root[i][l - 1] + D;
    }
  }
  if (d > -1) return true;
  return false;
}
int main() {
  int N, M;
  cin >> N >> M;
  root = vector<vector<int>>(N, vector<int>(N, -1));
  for (int i = 0; i < M; i++) {
    int L, R, D;
    cin >> L >> R >> D;
    if (is_root(N, L, R, D)) {
      if (d != D) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
