#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long infl = 1e17;
int main() {
  long long n, m;
  cin >> n >> m;
  set<long long> check;
  map<long long, map<long long, long long>> branch;
  long long l, r, d;
  for (long long i = 0; i < (long long)m; i++) {
    cin >> l >> r >> d;
    l--;
    r--;
    check.insert(l);
    check.insert(r);
    branch[l][r] = d;
    branch[r][l] = -d;
  }
  vector<long long> dist(n, infl);
  while (!(check.empty())) {
    long long start = *check.begin();
    check.erase(start);
    if (dist[start] != infl) continue;
    dist[start] = 0;
    set<long long> c;
    c.insert(start);
    while (!(c.empty())) {
      long long now = *c.begin();
      c.erase(now);
      for (auto p : branch[now]) {
        if (dist[p.first] == infl) {
          dist[p.first] = dist[now] + p.second;
          c.insert(p.first);
        } else if (dist[p.first] != dist[now] + p.second) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  long long MIN = infl, MAX = -infl;
  for (long long i = 0; i < (long long)n; i++) {
    MIN = min(dist[i], MIN);
    MAX = max(dist[i], MAX);
  }
  if (MAX - MIN <= 1e9) {
    cout << "Yes" << endl;
  } else
    cout << "No" << endl;
}
