#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c;
  int n;
  cin >> n;
  int m;
  cin >> m;
  int p[100000] = {};
  int l, r, d;
  for (a = 0; a < m; a++) {
    cin >> l >> r >> d;
    if (p[l] != 0 && p[r] != 0) {
      if (p[r] - p[l] != d) {
        cout << "No" << endl;
        return 0;
      }
    } else if (p[l] != 0) {
      p[r] = p[l] + d;
    } else if (p[r] != 0) {
      p[l] = p[r] - d;
    } else {
      p[l] = 114514;
      p[r] = p[l] + d;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
