#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LLINF = 1e18;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> x(n + 1, -1);
  vector<tuple<int, int, int>> lrd;
  for (int i = (0); i < (m); i++) {
    int l, r, d;
    cin >> l >> r >> d;
    lrd.push_back(make_tuple(l, r, d));
  }
  bool ans = true;
  while (!lrd.empty()) {
    bool updated = false;
    for (int i = (0); i < ((int)lrd.size()); i++) {
      int l = get<0>(lrd[i]);
      int r = get<1>(lrd[i]);
      int d = get<2>(lrd[i]);
      if (x[l] == -1 && x[r] == -1) {
        continue;
      } else if (x[l] != -1 && x[r] != -1) {
        if (x[l] + d != x[r]) ans = false;
        lrd.erase(lrd.begin() + i);
        updated = true;
        break;
      } else if (x[l] != -1) {
        x[r] = x[l] + d;
        updated = true;
        break;
      } else {
        x[l] = x[r] - d;
        updated = true;
        break;
      }
    }
    if (!updated) {
      x[get<0>(lrd[0])] = 0;
    }
    if (!ans) break;
  }
  cout << ((ans) ? "Yes" : "No") << endl;
  return 0;
}
