#include <bits/stdc++.h>
using namespace std;
const long long inf = (1LL) << 40;
struct ed {
  int to, next;
  int v;
} e[100005 << 2];
int h[100005], vis[100005], cc[100005], tr[100005];
long long d[100005];
int o, n, m;
void add(int x, int y, int z) {
  e[o].to = y;
  e[o].v = z;
  e[o].next = h[x];
  h[x] = o++;
}
bool spfa(int v) {
  memset(vis, 0, sizeof(vis));
  ;
  memset(cc, 0, sizeof(cc));
  ;
  for (int i = 1; i <= n; i++) d[i] = inf;
  tr[1] = v;
  vis[v] = 1;
  d[v] = 0;
  cc[v] = 1;
  int hea = 0, tail = 1, now;
  while (hea != tail) {
    hea = (hea + 1) % 100005;
    now = tr[hea];
    for (int k = h[now]; k != -1; k = e[k].next) {
      v = e[k].to;
      vis[now] = 0;
      if (d[v] > d[now] + e[k].v) {
        d[v] = d[now] + e[k].v;
        if (!vis[v]) {
          tail = (tail + 1) % 100005;
          tr[tail] = v;
          vis[v] = 1;
          cc[v]++;
          if (cc[v] > n) return 0;
        }
      }
    }
  }
  return 1;
}
int main() {
  scanf("%d%d", &n, &m);
  int x, y, z;
  memset(h, 255, sizeof(h));
  ;
  o = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &x, &y, &z);
    add(x, y, -z);
    add(y, x, z);
  }
  int temp;
  for (int i = 1; i <= n; i++)
    if (!spfa(i)) {
      puts("No");
      return 0;
    }
  puts("Yes");
}
