#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int maxn = 1e5 + 19;
vector<pair<int, int>> g[maxn];
vector<int> x(maxn), v(maxn), cv;
int n, m;
bool possible = true;
int dfs(int i) {
  v[i] = true;
  for (auto it : g[i]) {
    if (!v[it.first]) {
      x[it.first] = x[i] + it.second;
      dfs(it.first);
    } else if (x[it.first] != x[i] + it.second) {
      possible = false;
    }
  }
  cv.push_back(i);
  return 0;
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  cin >> n >> m;
  for (int i = 0; i < (m); ++i) {
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    g[l].push_back(make_pair(r, d));
    g[r].push_back(make_pair(l, -d));
  }
  for (int i = 0; i < (n); ++i) {
    if (v[i] == 0) {
      dfs(i);
      int minm = 0;
      for (int it : cv) minm = min(minm, x[it]);
      for (int it : cv) x[it] += minm;
    }
  }
  if (possible) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
