#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
vector<vector<pair<int, long long> > > P;
vector<long long> D;
int dfs(int c, long long x) {
  if (D[c] != -1) {
    return ((D[c] == x) ? 1 : 0);
  }
  D[c] = x;
  int ret = 1;
  for (int i = 0; i < P[c].size(); i++) {
    ret = min(ret, dfs(P[c][i].first, x + P[c][i].second));
  }
  return ret;
}
int main() {
  int N, M;
  cin >> N >> M;
  P.resize(N);
  D.resize(N, -1);
  for (int i = 0; i < M; i++) {
    int l, r;
    long long d;
    cin >> l >> r >> d;
    l--;
    r--;
    P[l].push_back(make_pair(r, d));
  }
  bool ans = true;
  for (int i = 0; i < N; i++) {
    fill(D.begin(), D.end(), -1);
    if (dfs(i, 0) == 0) {
      ans = false;
      break;
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}
