#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int l[m], r[m], d[m];
  for (int i = (int)0; i < (int)m; i++) {
    cin >> l[i] >> r[i] >> d[i];
    l[i]--;
    r[i]--;
  }
  int rsl[n];
  for (int i = (int)0; i < (int)n; i++) rsl[i] = 1e9;
  rsl[l[0]] = 0;
  rsl[r[0]] = d[0];
  for (int i = (int)1; i < (int)m; i++) {
    if (rsl[l[i]] == 1e9) {
      if (rsl[r[i]] == 1e9) {
        rsl[l[i]] = 0;
        rsl[r[i]] = d[i];
      } else {
        rsl[l[i]] = rsl[r[i]] - d[i];
      }
    } else {
      if (rsl[r[i]] == 1e9) {
        rsl[r[i]] = rsl[l[i]] + d[i];
      } else {
        if (rsl[r[i]] != (rsl[l[i]] + d[i])) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
}
