#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, fh = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') fh = -1;
  for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ '0');
  return x * fh;
}
const int M = 1100 << 1, N = 2010;
int to[M], Head[N], Next[M], val[M], e;
void add_edge(int u, int v, int w) {
  to[++e] = v;
  val[e] = w;
  Next[e] = Head[u];
  Head[u] = e;
}
bool vis[N], flag;
int dis[N];
void bellman_ford(int u) {
  vis[u] = true;
  for (int i = Head[u]; i; i = Next[i]) {
    int v = to[i];
    if (dis[v] > dis[u] + val[i]) {
      if (vis[v]) {
        flag = true;
        return;
      }
      dis[v] = dis[u] + val[i];
      bellman_ford(v);
    }
  }
  vis[u] = false;
}
void init() {
  e = 0;
  memset(Head, 0, sizeof(Head));
  memset(vis, false, sizeof(vis));
  memset(dis, 0x3f, sizeof(dis));
  flag = false;
}
int main() {
  init();
  int n = read(), m = read();
  while (m--) {
    int l = read(), r = read(), s = read();
    add_edge(l, r, s);
    add_edge(r, l, -s);
  }
  for (int i = (1); i <= (int)(n); ++i) {
    if (!vis[i]) bellman_ford(i);
    if (flag) break;
  }
  printf("%s\n", !flag ? "Yes" : "No");
}
