#include <bits/stdc++.h>
using namespace std;
struct edge {
  long long to, cost;
};
vector<edge> g[200000];
long long d[100000];
bool ans = true;
void dfs(long long now) {
  long long i;
  for (i = 0; i < (g[now].size()); i++) {
    long long next = g[now][i].to;
    long long c = g[now][i].cost;
    if (d[next] == -1) {
      d[next] = d[now] + c;
      dfs(next);
    } else if (d[next] != d[now] + c) {
      ans = false;
      return;
    }
  }
}
signed main(void) {
  long long i, j;
  long long n, m;
  cin >> n >> m;
  for (i = 0; i < (m); i++) {
    long long l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    edge e;
    e.to = r;
    e.cost = d;
    g[l].push_back(e);
  }
  fill(d, d + n, -1);
  d[0] = 0;
  for (i = 0; i < (n); i++) dfs(i);
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
