#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, int>;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<P>> G(n);
  vector<int> deg(n, 0);
  for (int i = 0; i < m; i++) {
    int r, l;
    ll d;
    cin >> r >> l >> d;
    r--;
    l--;
    G[l].push_back(P(d, r));
    G[r].push_back(P(-d, l));
  }
  vector<ll> dist(n, -1);
  for (int i = 0; i < n; i++) {
    if (dist[i] != -1) continue;
    dist[i] = 0;
    queue<P> que;
    que.push(P(0ll, i));
    while (!que.empty()) {
      auto p = que.front();
      que.pop();
      ll d = p.first;
      int v = p.second;
      for (auto nv : G[v]) {
        if (dist[nv.second] == -1) {
          dist[nv.second] = dist[v] + nv.first;
          que.push(P(dist[v] + nv.first, nv.second));
        } else if (dist[nv.second] != dist[v] + nv.first) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
