#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, M;
  cin >> N >> M;
  vector<map<int, int>> dist(N);
  for (int i = 0; i < (int)(M); ++i) {
    int L, R, D;
    cin >> L >> R >> D;
    L--;
    R--;
    if (dist[L].find(R) != dist[L].end()) {
      if (dist[L][R] != D) {
        cout << "No" << endl;
        return 0;
      }
    }
    if (dist[R].find(L) != dist[R].end()) {
      cout << "No" << endl;
      return 0;
    }
    dist[L][R] = D;
    for (auto& x : dist[R]) {
      dist[L][x.first] = D + x.second;
    }
    for (auto& mp : dist) {
      if (mp.find(L) != mp.end()) {
        mp[R] = mp[L] + D;
      }
    }
  }
  cout << "Yes" << endl;
}
