#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = 1e15;
bool ans = true;
const long long MaxN = 100001;
vector<pair<long long, long long> > d[MaxN];
long long D[MaxN];
bool Used[MaxN];
void solve(long long y) {
  long long K = d[y].size();
  if (K == 0) return;
  if (!ans) return;
  for (int i = 0; i < K; i++) {
    long long X = d[y].at(i).first, Y = d[y].at(i).second;
    if (D[Y] != INF) {
      if (D[Y] != X + D[y]) ans = false;
    } else {
      D[Y] = X + D[y];
      solve(Y);
    }
  }
  return;
}
int main() {
  long long N, M;
  cin >> N >> M;
  for (int i = 0; i < MaxN; i++) Used[i] = true;
  for (int i = 0; i < MaxN; i++) D[i] = INF;
  for (int i = 0; i < M; i++) {
    long long L, R, DD;
    cin >> L >> R >> DD;
    Used[L] = false;
    Used[R] = false;
    d[L].push_back(make_pair(DD, R));
    d[R].push_back(make_pair(-DD, L));
  }
  for (int i = 0; i < N + 1; i++)
    if (!Used[i]) solve(i);
  if (ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
