#include <bits/stdc++.h>
using namespace std;
using in = int64_t;
const double PI = 3.14159265358979323846;
const in MOD = 1000000007;
const in INF = 1 << 30;
using P = pair<int, int>;
vector<int> dx = {0, 1, -1, 0};
vector<int> dy = {1, 0, 0, -1};
vector<int> par(0);
vector<int> depth(0);
vector<int> heavy(0);
void init(int n) {
  par.resize(n);
  depth.resize(n, 0);
  heavy.resize(n, 0);
  for (int i = 0; i < (int)(n); i++) par[i] = i;
}
int find(int n) {
  if (par[n] == n) return n;
  int parent = find(par[n]);
  heavy[n] += heavy[par[n]];
  return par[n] = parent;
}
int wei(int x) {
  find(x);
  return heavy[x];
}
void unite(int x, int y, int z) {
  z = z + wei(x) - wei(y);
  x = find(x);
  y = find(y);
  if (par[x] == par[y]) return;
  if (depth[x] < depth[y]) {
    par[x] = par[y];
    heavy[x] += z;
  } else {
    par[y] = par[x];
    heavy[y] -= z;
    if (depth[x] == depth[y]) depth[x]++;
  }
}
bool same(int x, int y) { return find(x) == find(y); }
int diff(int x, int y) {
  if (!same(x, y)) return -1;
  return wei(x) - wei(y);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int n, m, l, r, d;
  cin >> n >> m;
  init(n);
  for (int i = 0; i < (int)(m); i++) {
    cin >> r >> l >> d;
    r--;
    l--;
    if (diff(l, r) == -d)
      continue;
    else if (same(l, r)) {
      cout << "No" << endl;
      return 0;
    } else
      unite(l, r, d);
  }
  cout << "Yes" << endl;
}
