#include <bits/stdc++.h>
using namespace std;
struct people {
  int par;
  long long d;
};
vector<struct people> uf;
int find(int a) {
  if (a == uf[a].par)
    return uf[a].par;
  else {
    int b = find(uf[a].par);
    uf[a].d += uf[uf[a].par].d;
    uf[a].par = b;
    return uf[a].par;
  }
}
bool uni(int l, int r, int d) {
  int lp = find(l);
  int rp = find(r);
  if (lp == rp) {
    if (uf[r].d - uf[l].d == d)
      return true;
    else
      return false;
  }
  uf[rp].par = l;
  uf[rp].d += d;
  return true;
}
int main() {
  int n, m;
  cin >> n >> m;
  uf = vector<struct people>(n + 1);
  for (int i = 0; i <= n; i++) uf[i] = {i, 0};
  bool ans = true;
  int l, r, d;
  for (int i = 0; i < m; i++) {
    cin >> l >> r >> d;
    ans &= uni(l, r, d);
  }
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
