#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  int l1, r1, d1;
  int l2, r2;
  int l3, r3, d3;
  int e[100000];
  long long int f[100000];
  queue<int> l, r, d;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> l1 >> r1 >> d1;
    l.push(l1);
    r.push(r1);
    d.push(d1);
  }
  for (int i = 0; i < n; i++) {
    e[i] = 0;
  }
  l2 = l.front();
  r2 = r.front();
  while (l.size()) {
    l3 = l.front();
    r3 = r.front();
    d3 = d.front();
    l.pop();
    r.pop();
    d.pop();
    if (e[l3] == 0 && e[r3] == 0) {
      if (l2 == l3 && r2 == r3) {
        f[l2] = 0;
        f[r2] = d3;
      }
      l.push(l3);
      r.push(r3);
      d.push(d3);
    } else if (e[l3] == 0 && e[r3] == 1) {
      f[l3] = f[r3] - d3;
      l2 = l.back();
      r2 = r.back();
    } else if (e[l3] == 1 && e[r3] == 0) {
      f[r3] = f[l3] + d3;
      l2 = l.back();
      r2 = r.back();
    } else {
      if (f[r3] != (f[l3] + d3)) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}
