#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<pair<int, int> > > g;
bool hako[111111];
int kyori[111111];
bool dfs(int x, int d) {
  if (kyori[x] == -1)
    kyori[x] = d;
  else if (kyori[x] != d)
    return false;
  for (int i = 0; i < g[x].size(); i++) {
    if (!dfs(g[x][i].first, d + g[x][i].second)) return false;
  }
  return true;
}
int main(void) {
  cin >> n >> m;
  int l, r, d;
  g.resize(n + 1, vector<pair<int, int> >());
  memset(kyori, -1, sizeof kyori);
  for (int i = 0; i < m; i++) {
    cin >> l >> r >> d;
    g[l].push_back(pair<int, int>(r, d));
    hako[r] = true;
  }
  bool f = true;
  for (int i = 1; i <= n; i++) {
    if (hako[i]) continue;
    if (!dfs(i, 0)) {
      f = false;
      break;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (kyori[i] == -1) f = false;
  }
  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
