#include <bits/stdc++.h>
using namespace std;
struct edge {
  int from, to;
  long long cost;
};
vector<long long> d;
int V, E;
vector<edge> edges;
int bellman_ford(long long start) {
  for (int i = 0; i < V; i++) {
    d.push_back(INT_MAX);
  }
  d[start] = 0;
  bool update = true;
  int loop_cnt = 0;
  while (update) {
    update = false;
    for (int i = 0; i < E; i++) {
      edge e = edges[i];
      if (d[e.from] != INT_MAX && d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
        update = true;
      }
    }
    loop_cnt++;
    if (update && loop_cnt == V) return 0;
  }
  return 1;
}
int main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  V = n;
  E = 0;
  if (m == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  for (int i = 0; i < m; i++) {
    edge e;
    cin >> e.from >> e.to >> e.cost;
    edges.emplace_back(e);
    swap(e.from, e.to);
    e.cost *= -1;
    edges.emplace_back(e);
    E += 2;
    if (!bellman_ford(e.from)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
