#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
vector<pair<long long int, long long int>> g[N];
bool vis[N];
long long int n, m, x[N], l[N], r[N], d[N];
void dfs(long long int s, long long int par, long long int dist) {
  x[s] = x[par] + dist;
  vis[s] = 1;
  for (auto d : g[s]) {
    if (vis[d.first]) continue;
    long long int dis = d.second;
    dfs(d.first, s, dis);
  }
}
void solve() {
  cin >> n >> m;
  for (long long int i = 0; i < m; i++) {
    cin >> l[i] >> r[i] >> d[i];
    g[l[i]].push_back({r[i], d[i]});
    g[r[i]].push_back({l[i], -1LL * d[i]});
  }
  for (long long int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i, 0, 0);
  for (long long int i = 0; i < n; i++) {
    if (x[r[i]] - x[l[i]] != d[i]) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int T = 1;
  while (T--) solve();
  return 0;
}
