#include <bits/stdc++.h>
using namespace std;
struct LRD {
  int L, R, D;
};
signed main() {
  queue<LRD> Q;
  int N, M;
  LRD q;
  cin >> N >> M;
  vector<int> x(N);
  vector<bool> flag(N, false);
  for (int i = 0; i < M; i++) {
    cin >> q.L >> q.R >> q.D;
    Q.push(q);
  }
  q = Q.front();
  Q.pop();
  flag[q.L - 1] = true;
  flag[q.R - 1] = true;
  x[q.L - 1] = 100;
  x[q.R - 1] = x[q.L - 1] + q.D;
  while (!Q.empty()) {
    q = Q.front();
    Q.pop();
    if (flag[q.L - 1] && flag[q.R - 1]) {
      if (x[q.R - 1] - x[q.L - 1] != q.D) {
        cout << "No" << endl;
        return 0;
      }
    } else if (flag[q.L - 1]) {
      flag[q.R - 1] = true;
      x[q.R - 1] = x[q.L - 1] + q.D;
    } else if (flag[q.R - 1]) {
      flag[q.L - 1] = true;
      x[q.L - 1] = x[q.R - 1] - q.D;
    } else {
      Q.push(q);
    }
  }
  cout << "Yes" << endl;
  return 0;
}
