#include <bits/stdc++.h>
using namespace std;
int N, M, l, r, d;
int dist[100001];
bool dupchk[100001];
bool isspos[100001];
vector<vector<pair<int, int> > > G;
bool dfs(int v, int ranksum = -1) {
  dupchk[v] = true;
  if (ranksum >= 0) dist[v] = ranksum;
  if (ranksum == -1 && G[v].size() >= 2) ranksum = 0;
  for (int e = 0; e < G[v].size(); ++e) {
    if (dupchk[G[v][e].first]) {
      return true;
    }
    if (ranksum >= 0 && dist[G[v][e].first] >= 0 &&
        dist[G[v][e].first] != G[v][e].second + ranksum) {
      return true;
    }
    if (dfs(G[v][e].first, ranksum >= 0 ? G[v][e].second + ranksum : -1))
      return true;
  }
  dupchk[v] = false;
  return false;
}
int main(void) {
  scanf("%d %d", &N, &M);
  for (int n = 0; n < N; ++n) {
    G.push_back(vector<pair<int, int> >());
    dist[n] = -1;
    dupchk[n] = false;
    isspos[n] = true;
  }
  for (int m = 0; m < M; ++m) {
    scanf("%d %d %d", &l, &r, &d);
    --l;
    --r;
    G[r].push_back(pair<int, int>(l, d));
    isspos[l] = false;
  }
  bool fail = false;
  for (int n = 0; n < N && !fail; ++n) fail |= dfs(n);
  if (fail)
    printf("No");
  else
    printf("Yes");
  return 0;
}
