#include <bits/stdc++.h>
using namespace std;
int N, M;
void solve() {
  cin >> N >> M;
  vector<vector<int> > info(M);
  for (int i = 0; i < M; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    info[i] = vector<int>({l, r, d});
  }
  sort(info.begin(), info.end());
  map<int, int> mp;
  for (int i = 0; i < M; i++) {
    if (!mp.count(info[i][0]) && !mp.count(info[i][1])) {
      mp[info[i][0]] = 0;
      mp[info[i][1]] = info[i][2];
    } else if (mp.count(info[i][0]) && mp.count(info[i][1])) {
      if (mp[info[i][0]] + info[i][2] != mp[info[i][1]]) {
        cout << "No" << endl;
        return;
      }
    } else if (mp.count(info[i][0])) {
      mp[info[i][1]] = mp[info[i][0]] + info[i][2];
    } else if (mp.count(info[i][1])) {
      mp[info[i][0]] = mp[info[i][1]] - info[i][2];
    }
  }
  cout << "Yes" << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
