#include <bits/stdc++.h>
using namespace std;
const static int MOD = 1000000000 + 7;
const static long long int INF = 1LL << 60;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};
int main(int argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  if (m == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  vector<vector<pair<int, long long int> > > G(n);
  int l, r, d;
  for (int i = 0; i < m; ++i) {
    cin >> l >> r >> d;
    G[r - 1].push_back(make_pair(l - 1, -d));
  }
  bool check_closed_circuit = false;
  vector<long long int> dist(n, INF);
  dist[r - 1] = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      for (int k = 0; k < G[j].size(); ++k) {
        if (dist[j] != INF && dist[G[j][k].first] > dist[j] + G[j][k].second) {
          dist[G[j][k].first] = dist[j] + G[j][k].second;
          if (i == n - 1) check_closed_circuit = true;
        }
      }
    }
  }
  if (check_closed_circuit) {
    cout << "No" << endl;
    return 0;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}
