#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<pair<int, int> > G[100010];
int vis[100010], dis[100010];
int l[100010], r[100010], d[100010];
void dfs(int x) {
  vis[x] = 1;
  for (int i = 0; i < (int)G[x].size(); i++) {
    if (vis[G[x][i].first] == 0) {
      dis[G[x][i].first] = dis[x] + G[x][i].second;
      dfs(G[x][i].first);
    }
  }
}
int main(void) {
  int i;
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> N >> M;
  for (i = 0; i < 10005; i++) {
    l[i] = -1;
    r[i] = -1;
    d[i] = -1;
  }
  for (i = 0; i < M; i++) {
    int L, R, D;
    cin >> L >> R >> D;
    l[i] = L;
    r[i] = R;
    d[i] = D;
    G[L].push_back(pair<int, int>(R, D));
  }
  for (i = 0; i < N; i++) {
    if (l[i] == -1) continue;
    if (vis[i] == 0) {
      dis[l[i]] = 1;
      dfs(l[i]);
    }
  }
  for (i = 0; i < M; i++) {
    if ((dis[r[i]] - dis[l[i]]) != d[i]) {
      cout << "No" << endl;
      return 0;
    }
  }
  int mn = 1e9, mx = 0;
  for (i = 0; i < N; i++) {
    mn = min(mn, dis[i]);
    mx = max(mx, dis[i]);
  }
  if (mx - mn > 1e9) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}
