#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;
int dist[114514];
void dfs(int x, int d) {
  if (dist[x] != -1) {
    if (dist[x] != d) ok = false;
    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;
  g.resize(n + 1);
  for (int i = 0; i < (m); ++i) {
    int l, r, d;
    cin >> l >> r >> d;
    if (r < l) swap(l, r);
    L.push_back(l);
    g[l].push_back({r, d});
  }
  memset(dist, -1, sizeof(dist));
  for (auto &&e : L) {
    dfs(e, dist[e]);
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
