#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using vlai = valarray<int>;
using ll = long long;
using pii = pair<ll, ll>;
void bulk() {}
template <class H, class... T>
void bulk(H& h, T&... t) {
  cin >> h;
  bulk(t...);
}
int main() {
  int n, m;
  bulk(n, m);
  ;
  vector<vector<pii>> edge(n + 1);
  for (int i = 0; i < m; i++) {
    int l, r, dst;
    bulk(l, r, dst);
    ;
    edge[l].emplace_back(r, dst);
  }
  vi dist(n + 1, -1);
  for (int i = 1; i < n + 1; i++) {
    if (dist[i] != -1 || edge[i].empty()) continue;
    dist[i] = 0;
    queue<int> q;
    q.push(i);
    int mn = 1e9, mx = -1e9;
    set<int> current;
    current.insert(i);
    while (!q.empty()) {
      int t = q.front();
      q.pop();
      mn = min(mn, dist[t]);
      mx = max(mx, dist[t]);
      for (auto p : edge[t]) {
        if (dist[p.first] != -1) {
          if (current.find(p.first) != current.end()) {
            if (dist[t] + p.second != dist[p.first]) {
              cout << "No" << endl;
              return 0;
            }
          } else {
            for (auto j : current) {
              dist[j] += dist[p.first] - p.second;
            }
          }
        } else {
          dist[p.first] = dist[t] + p.second;
          q.push(p.first);
          current.insert(p.first);
        }
      }
    }
    if (mx - mn > 1e9) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
