#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
const string YES = "Yes";
const string NO = "No";
struct UnionFindWeighted {
  vll par;
  vll parDist;
  vll rank;
  UnionFindWeighted(ll n) {
    par = vll(n);
    parDist = vll(n, 0);
    rank = vll(n, 0);
    for (ll i = 0; i < n; i++) par[i] = i;
  }
  pll find(ll x) {
    if (par[x] == x)
      return pll(x, 0);
    else {
      pll tmp = find(par[x]);
      par[x] = tmp.first;
      parDist[x] += tmp.second;
      return make_pair(par[x], parDist[x]);
    }
  }
  void unite(ll x, ll y, ll d) {
    pll px = find(x), py = find(y);
    if (px.first == py.first) return;
    if (rank[x] < rank[y]) {
      par[x] = py.first;
      parDist[x] = py.second - d;
    } else {
      par[y] = px.first;
      parDist[y] = px.second + d;
      if (rank[x] == rank[y]) rank[x]++;
    }
  }
  bool same(ll x, ll y) { return find(x).first == find(y).first; }
};
void solve(long long N, long long M, std::vector<long long> L,
           std::vector<long long> R, std::vector<long long> D) {
  UnionFindWeighted uf(N);
  for (ll i = 0; i < M; i++) {
    uf.unite(L[i] - 1, R[i] - 1, D[i]);
  }
  bool isGood = true;
  for (ll i = 0; i < M; i++) {
    ll x = L[i] - 1, y = R[i] - 1, d = D[i];
    if (uf.find(y).second - uf.find(x).second != d) {
      isGood = false;
      break;
    }
  }
  if (isGood)
    cout << YES << endl;
  else
    cout << NO << endl;
}
int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> L(M);
  std::vector<long long> R(M);
  std::vector<long long> D(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &L[i]);
    scanf("%lld", &R[i]);
    scanf("%lld", &D[i]);
  }
  solve(N, M, std::move(L), std::move(R), std::move(D));
  return 0;
}
