#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 5, maxm = 2e5 + 5;
struct node {
  long long w, v, nxt;
} edge[maxm];
long long n, m, head[maxn];
bool ok[maxn];
template <typename T>
void read(T &ans) {
  T f = 1;
  char c = getchar();
  ans = 0;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    ans = ans * 10 + c - '0';
    c = getchar();
  }
  ans *= f;
}
long long cnt = 0;
void link(long long u, long long v, long long w) {
  edge[++cnt].v = v;
  edge[cnt].w = w;
  edge[cnt].nxt = head[u];
  head[u] = cnt;
}
long long d[maxn], edge_num[maxn];
bool vis[maxn];
queue<long long> q;
bool spfa(long long src) {
  memset(vis, 0, sizeof vis);
  memset(d, 0x3f, sizeof d);
  d[src] = 0, vis[src] = 1, edge_num[src] = 0;
  q.push(src);
  while (!q.empty()) {
    long long u = q.front();
    q.pop();
    vis[u] = 0;
    ok[u] = 0;
    for (long long e = head[u]; e; e = edge[e].nxt) {
      long long v = edge[e].v, w = edge[e].w;
      if (d[v] > d[u] + w) {
        d[v] = d[u] + w;
        edge_num[v] = edge_num[u] + 1;
        if (edge_num[v] > n) return false;
        if (!vis[v]) {
          q.push(v);
          vis[v] = 1;
        }
      }
    }
  }
  return true;
}
long long srcnow = 100001;
signed main() {
  read(n);
  read(m);
  cnt = 0;
  memset(ok, 0, sizeof ok);
  for (long long i = 1; i <= m; i++) {
    long long x, y, D;
    read(x), read(y), read(D);
    link(y, x, D);
    link(x, y, -D);
    link(srcnow, x, 0);
    link(srcnow, y, -0);
    ok[x] = ok[y] = 1;
  }
  if (spfa(srcnow))
    puts("Yes");
  else
    puts("No");
  return 0;
}
