#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LINF = 1e18;
using namespace std;
typedef struct Edge {
  long long to, cost;
} Edge;
vector<vector<Edge>> g;
bool ok = true;
long long dist[114514];
void dfs(int x, long long d) {
  if (dist[x] != 0) return;
  dist[x] = d;
  for (auto &&e : g[x]) dfs(e.to, d + e.cost);
  return;
}
int main(int argc, char const *argv[]) {
  int n, m;
  cin >> n >> m;
  vector<long long> l(m), r(m), d(m);
  g.resize(n);
  for (int i = 0; i < (m); ++i) {
    cin >> l[i] >> r[i] >> d[i];
    --l[i], --r[i];
    g[l[i]].push_back({r[i], d[i]});
    g[r[i]].push_back({l[i], -1 * d[i]});
  }
  memset(dist, 0, sizeof(dist));
  for (int i = 0; i < n; ++i) dfs(i, 0);
  for (int i = 0; i < (m); ++i) {
    if (dist[r[i]] - dist[l[i]] != d[i]) ok = false;
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
