#include <bits/stdc++.h>
using namespace std;
struct st {
  int L, R, D;
};
int main() {
  int N, M;
  cin >> N >> M;
  if (M == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  vector<st> S(M);
  vector<vector<pair<int, int>>> mp(N + 1);
  for (int i = 0; i < M; i++) {
    cin >> S[i].L >> S[i].R >> S[i].D;
    mp[S[i].L].push_back({S[i].R, S[i].D});
    mp[S[i].R].push_back({S[i].L, -S[i].D});
    if (S[i].L > S[i].R) {
      swap(S[i].L, S[i].R);
      S[i].D *= -1;
    }
  }
  sort(S.begin(), S.end(),
       [&](const st& lsh, const st& rhs) { return (lsh.L < rhs.L); });
  vector<long long> pos(N + 1, INT_MIN);
  stack<int> sta;
  sta.push(S[0].L);
  pos[S[0].L] = 0;
  while (!sta.empty()) {
    int target = sta.top();
    sta.pop();
    for (auto p : mp[target]) {
      if (pos[p.first] != INT_MIN) {
        if (pos[p.first] - pos[target] != p.second) {
          cout << "No" << endl;
          return 0;
        }
      } else {
        pos[p.first] = pos[target] + p.second;
        sta.push(p.first);
      }
    }
  }
  cout << "Yes" << endl;
}
