#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
vector<int> par;
vector<ll> dfromr;
int root(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = root(par[x]);
  }
}
int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i <= M; i++) {
    par.push_back(i);
    dfromr.push_back(0);
  }
  for (int i = 0; i < M; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    if (root(l) == root(r)) {
      if (dfromr[r] != dfromr[l] + d) {
        cout << "No";
        return 0;
      }
    }
    par[r] = root(l);
    dfromr[r] = dfromr[l] + d;
  }
  for (int i = 1; i <= M; i++) {
    if (dfromr[i] > 1e9) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
  return 0;
}
