#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll N, M;
vector< vector<pll> > E;
vector<bool> used;
vector<ll> X;

bool dfs(ll v, ll x) {
  if(used[v]) return X[v] == x;
  used[v] = true;
  X[v] = x;

  bool ret = true;
  for(pll p : E[v]) {
    ll u = p.first, d = p.second;
    ret = ret && dfs(u, x + d);
  }
  return ret;
}

int main(void) {
  cin >> N >> M;
  E.resize(N);
  REP(i, 0, M) {
    ll L, R, D;
    cin >> L >> R >> D;
    L--;
    R--;
    E[L].push_back(pll(R, +D));
    E[R].push_back(pll(L, -D));
  }

  bool ans = true;
  used.resize(N, false);
  X.resize(N);
  REP(i, 0, N) if(!used[i]) ans = ans && dfs(i, 0);
  cout << (ans ? "Yes" : "No") << endl;
}
