#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n;
  cin >> m;
  int l[210000];
  int r[210000];
  int d[210000];
  int flag = 1;
  int x[110000] = {};
  bool flagx[110000] = {};
  for (int i = 1; i <= m; i++) {
    cin >> l[i];
    cin >> r[i];
    cin >> d[i];
    if (flagx[r[i]] == 0) {
      x[r[i]] = x[l[i]] + d[i];
      flagx[r[i]] = 1;
      flagx[l[i]] = 1;
    } else if (flagx[l[i]] == 0) {
      x[l[i]] = x[r[i]] - d[i];
      flagx[l[i]] = 1;
    } else {
      if (x[r[i]] != x[l[i]] + d[i]) {
        flag = 0;
        break;
      }
    }
  }
  if (flag)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
