#include <bits/stdc++.h>
using namespace std;
const long long inf = 1000000007LL;
const double EPS = 1e-10;
const long long inf_ll = (long long)1e18;
const long long maxn = 100005LL;
const long long maxm = 200005LL;
const long long mod = 1000000009LL;
struct Graph {
  struct edge {
    int u, v, nxt, w;
    edge() {}
    edge(int nu, int nv, int nnxt, int nw) : u(nu), v(nv), nxt(nnxt), w(nw) {}
  } E[maxm * 2];
  int cnt, head[maxn];
  inline void link(int u, int v, int w) {
    E[++cnt] = edge(u, v, head[u], w);
    head[u] = cnt;
  }
} G1, G2, G;
int n, m;
int dist[maxn];
int vis[maxn];
int dfs(int u, int d) {
  if (vis[u]) {
    if (dist[u] > d)
      return 1;
    else
      return 0;
  }
  dist[u] = d;
  vis[u] = 1;
  for (register int(i) = G.head[u]; (i); (i) = G.E[i].nxt) {
    int v = G.E[i].v, w = G.E[i].w;
    if (dfs(v, d + w)) return 1;
  }
  return 0;
}
int main() {
  scanf("%d%d", &n, &m);
  for (register int(i) = (1); (i) <= (m); ++i) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    G1.link(v, u, w);
    G1.link(u, v, -w);
    G2.link(u, v, w);
    G2.link(v, u, -w);
  }
  memset(vis, 0, sizeof(vis));
  G = G1;
  int ans = 0;
  for (register int(i) = (1); (i) <= (n); ++i)
    if (!vis[i]) {
      memset(dist, -1, sizeof(dist));
      ans |= dfs(i, 0);
    }
  memset(vis, 0, sizeof(vis));
  G = G2;
  for (register int(i) = (1); (i) <= (n); ++i)
    if (!vis[i]) {
      memset(dist, -1, sizeof(dist));
      ans |= dfs(i, 0);
    }
  if (!ans)
    puts("Yes");
  else
    puts("No");
  return 0;
}
