#include <bits/stdc++.h>
using namespace std;
struct edge {
  long long to, cost;
  edge() {}
  edge(long long t, long long c) : to(t), cost(c) {}
};
long long n, m;
long long L[100010], R[100010], D[100010];
vector<bool> used(100010);
vector<long long> d(100010), v;
vector<edge> G[100010];
bool tsort() {
  vector<long long> indeg(n);
  stack<long long> S;
  for (long long i = 0; i < n; i++) {
    for (auto &e : G[i]) {
      if (e.cost < 0) continue;
      indeg[e.to]++;
    }
  }
  for (long long i = 0; i < n; i++) {
    if (indeg[i] == 0) S.push(i);
  }
  while (S.size()) {
    long long u = S.top();
    S.pop();
    v.push_back(u);
    for (auto &e : G[u]) {
      if (e.cost < 0) continue;
      indeg[e.to]--;
      if (indeg[e.to] == 0) S.push(e.to);
    }
  }
  return v.size() == n;
}
bool dfs(int u) {
  bool res = true;
  for (auto &e : G[u]) {
    if (used[e.to] && d[e.to] != d[u] + e.cost) return false;
    if (!used[e.to]) {
      d[e.to] = d[u] + e.cost;
      used[e.to] = true;
      res &= dfs(e.to);
    }
  }
  return res;
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    cin >> L[i] >> R[i] >> D[i];
    L[i]--, R[i]--;
    G[L[i]].push_back(edge(R[i], D[i]));
    G[R[i]].push_back(edge(L[i], -D[i]));
  }
  if (!tsort()) {
    cout << "No\n";
    return 0;
  }
  for (int i = 0; i < v.size(); i++) {
    if (used[v[i]]) continue;
    d[v[i]] = 0;
    used[v[i]] = true;
    if (dfs(v[i])) continue;
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";
  return 0;
}
