#include <bits/stdc++.h>
using namespace std;
struct QWE {
  int t, c;
};
vector<QWE> a[100010];
bool vist[100010], l[100010];
int n, m, d[100010];
bool dfs(int x) {
  vist[x] = 1;
  for (int i = 0; i < a[x].size(); i++) {
    if (d[a[x][i].t] > d[x] + a[x][i].c)
      return 1;
    else {
      d[a[x][i].t] = d[x] + a[x][i].c;
      if (vist[a[x][i].t]) return 1;
      if (dfs(a[x][i].t)) return 1;
    }
  }
  vist[x] = 0;
  return false;
}
int main() {
  cin >> n >> m;
  if (m == 0) {
    cout << "Yes";
    return 0;
  }
  for (int i = 1; i <= m; i++) {
    int x, y, z;
    QWE u;
    cin >> x >> y >> z;
    u.t = y;
    u.c = z;
    a[x].push_back(u);
  }
  bool ok = 0;
  for (int i = 1; i <= n; i++) {
    if (dfs(i)) {
      ok = 1;
      break;
    }
  }
  if (ok == 1)
    cout << "No";
  else
    cout << "Yes";
  return 0;
}
