#include <bits/stdc++.h>
#pragma GCC optimize("O3")
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long llinf = LLONG_MAX;
const int inf = INT_MAX;
const int nmax = 2e5 + 5;
const int mod = 1e9 + 7;
using namespace std;
int n, m, i, x[nmax], ok, viz[nmax];
pair<int, pair<int, int> > a[nmax];
vector<int> v[nmax];
map<int, int> mp;
void dfs(int x, int p) {
  if (!ok) return;
  viz[x] = 1;
  if (p == mp[x]) {
    ok = 0;
    return;
  }
  mp[x] = p;
  for (int i = 0; i < v[x].size(); i++) dfs(v[x][i], x);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cerr.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (i = 1; i <= m; i++) {
    cin >> a[i].first >> a[i].second.first >> a[i].second.second;
    v[a[i].first].push_back(a[i].second.first);
  }
  sort(a + 1, a + m + 1);
  for (i = 1; i <= m; i++) {
    if (x[a[i].second.first] &&
        x[a[i].first] + a[i].second.second != x[a[i].second.first])
      return cout << "No" << endl, 0;
    x[a[i].second.first] = x[a[i].first] + a[i].second.second;
  }
  for (i = 1; i <= n; i++)
    if (!viz[i]) {
      ok = 1, dfs(i, -1);
      mp.clear();
      if (!ok) return cout << "No" << endl, 0;
    }
  return cout << "Yes" << endl, 0;
  return 0;
}
