#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int LOG = 20;
int n, m, pr[N], sz[N], in[N], out[N], timer, d[N], p[LOG][N];
bool was[N];
vector<pair<int, int> > g[N];
vector<pair<pair<int, int>, int> > q;
int parent(int x) {
  if (x == pr[x]) return x;
  return pr[x] = parent(pr[x]);
}
void unite(int a, int b) {
  a = parent(a);
  b = parent(b);
  if (a == b) return;
  if (sz[a] < sz[b]) {
    sz[b] += sz[a];
    pr[a] = b;
  } else {
    sz[a] += sz[b];
    pr[b] = a;
  }
}
void dfs(int x, int par) {
  was[x] = true;
  in[x] = timer;
  timer++;
  p[x][0] = par;
  for (auto p_to : g[x]) {
    int to = p_to.first;
    int dist = p_to.second;
    if (to == par) continue;
    d[to] = d[x] + dist;
    dfs(to, x);
  }
  out[x] = timer;
  timer++;
}
bool check(int a, int b) { return in[a] <= in[b] && out[a] >= out[b]; }
int lca(int a, int b) {
  if (check(a, b)) return a;
  if (check(b, a)) return b;
  int t = LOG - 1;
  while (true) {
    if (t < 0) return p[a][0];
    if (p[a][t] == -1) {
      t--;
      continue;
    }
    if (check(p[a][t], b)) {
      t--;
      continue;
    }
    a = p[a][t];
    t--;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    pr[i] = i;
    sz[i] = 1;
  }
  for (int i = 0; i < m; i++) {
    int a, b, d;
    cin >> a >> b >> d;
    a--;
    b--;
    q.push_back({{a, b}, d});
    if (parent(a) != parent(b)) {
      g[a].push_back({b, d});
      g[b].push_back({a, -d});
    }
    unite(a, b);
  }
  for (int i = 0; i < n; i++)
    if (!was[i]) dfs(i, -1);
  for (int i = 1; i < LOG; i++)
    for (int j = 0; j < n; j++)
      if (p[i - 1][j] == -1)
        p[i][j] = -1;
      else
        p[i][j] = p[i - 1][p[i - 1][j]];
  for (int i = 0; i < m; i++) {
    int a = q[i].first.first;
    int b = q[i].first.second;
    int dd = q[i].second;
    int c = lca(a, b);
    int dist = -d[a] + d[b];
    if (dist != dd) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}
