#include <bits/stdc++.h>
using namespace std;
static const long long MOD = 1e9 + 7;
static const long long INF = 1e25;
static const long long MAX_N = 100001;
long long v[100001];
vector<pair<long long, long long>> e[100001];
long long n, m;
void dfs(long long i, long long x) {
  v[i] = x;
  for (int p = 0; p < e[i].size(); p++) {
    long long nextID = e[i][p].first;
    long long nextDistance = e[i][p].second;
    if (v[nextID]) {
      if (v[i] + nextDistance != v[nextID]) {
        cout << "No";
        exit(0);
      }
    } else {
      dfs(nextID, v[i] + nextDistance);
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    long long l, r, d;
    cin >> l >> r >> d;
    e[l].push_back({r, d});
    e[r].push_back({l, -d});
  }
  for (int i = 1; i <= n; i++) {
    if (!v[i]) {
      dfs(i, 0);
    }
  }
  cout << "Yes" << endl;
  return 0;
}
