#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;
  if (m == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  map<long long, set<pair<long long, long long>>> branch;
  long long l, r, d;
  long long start;
  for (int i = 0; i < (int)m; i++) {
    cin >> l >> r >> d;
    branch[l - 1].insert(make_pair(r - 1, d));
    branch[r - 1].insert(make_pair(l - 1, -d));
    start = l - 1;
  }
  vector<long long> X(n, -infl);
  X[start] = 0;
  queue<long long> check;
  check.push(start);
  vector<bool> visited(n, false);
  while (!(check.empty())) {
    long long now = check.front();
    check.pop();
    visited[now] = true;
    for (auto p : branch[now]) {
      long long nex = p.first;
      long long d = p.second;
      if (X[nex] == -infl) {
        X[nex] = X[now] + d;
        check.push(nex);
      } else if (X[nex] != X[now] + d) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  long long MIN = infl, MAX = -infl;
  for (int i = 0; i < (int)n; i++) {
    if (X[i] > -infl) {
      MIN = min(MIN, X[i]);
      MAX = max(MAX, X[i]);
    }
  }
  if (MAX - MIN <= 1e9)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
