#include <bits/stdc++.h>
using namespace ::std;
template <class T>
istream& operator>>(istream& I, vector<T>& v) {
  for (T& e : v) I >> e;
  return I;
}
template <class T>
ostream& operator<<(ostream& O, const vector<T>& v) {
  for (const T& e : v) O << e << ' ';
  return O;
}
void _main() {
  int n, m;
  cin >> n >> m;
  vector<int> where(n + 1, INT_MIN);
  vector<array<int, 3> > info(m);
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < 3; j++) cin >> info[i][j];
    int a = info[i][0], b = info[i][1], c = info[i][2];
    if (where[a] == INT_MIN && where[b] == INT_MIN) {
      where[a] = 1;
      where[b] = 1 + c;
    } else if (where[a] != INT_MIN && where[b] == INT_MIN) {
      where[b] = where[a] + c;
    } else if (where[a] == INT_MIN && where[b] != INT_MIN) {
      where[a] = where[b] - c;
    }
  }
  for (array<int, 3> t : info) {
    if (where[t[1]] - where[t[0]] != t[2]) {
      cout << "No";
      return;
    }
  }
  cout << "Yes";
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int _t = 1;
  while (_t--) _main();
  return 0;
}
