#include <bits/stdc++.h>
using namespace std;
long long int l, x, y, n, m, i, z, p, s, e, j, k, c, d, t, h, q;
long long int visited[10000001], dis[10000001];
vector<pair<long long int, long long int> > v[10000001];
void dijkstra(long long int s) {
  priority_queue<pair<long long int, long long int> > q;
  q.push({0, s});
  dis[s] = 0;
  while (!q.empty()) {
    k = q.top().second;
    q.pop();
    if (visited[k]) continue;
    visited[k] = 1;
    for (auto x : v[k]) {
      p = x.first, d = x.second;
      if (dis[p] > dis[k] + d) {
        dis[p] = dis[k] + d;
        q.push({-dis[p], p});
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  map<pair<long long int, long long int>, long long int> ma;
  for (long long int i = 0; i < m; i++) {
    cin >> x >> y >> z;
    v[x].push_back({y, z});
    ma[{x, y}] = z;
  }
  for (i = 1; i <= n; i++) {
    dis[i] = 100000000007;
  }
  for (i = 1; i <= n; i++) {
    if (visited[i] == 0) {
      dijkstra(i);
    }
    for (j = 1; j <= n; j++) visited[j] = 0;
  }
  for (auto x : ma) {
    p = x.first.first;
    q = x.first.second;
    y = x.second;
    if (abs((dis[q] - dis[p])) != y) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}
