#include <bits/stdc++.h>
using namespace std;
int n, m, doe;
int pre[404040], son[404040], now[101010];
long long f[101010], v[404040];
bool br[101010], ok[101010];
int du[101010];
int que[1010101];
void add(int x, int y, long long z) {
  ++doe;
  pre[doe] = now[x];
  now[x] = doe;
  son[doe] = y;
  v[doe] = z;
}
bool spfa(int st) {
  int head = 1, tail = 1;
  que[1] = st;
  f[st] = 0;
  ok[st] = 1;
  br[st] = 1;
  while (head <= tail) {
    int x = que[head];
    br[x] = 0;
    ++du[x];
    if (du[x] >= n) return 1;
    int p = now[x];
    while (p) {
      int y = son[p];
      if (f[y] > f[x] + v[p] || ok[y] == 0) {
        ok[y] = 1;
        f[y] = f[x] + v[p];
        if (br[y] == 0) {
          br[y] = 1;
          ++tail;
          que[tail] = y;
        }
      }
      p = pre[p];
    }
    ++head;
  }
  return 0;
}
int main() {
  scanf("%d%d", &n, &m);
  int x, y, z;
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d%d", &x, &y, &z);
    add(x, y, z);
    add(y, x, -z);
  }
  for (int i = 1; i <= n; ++i)
    if (ok[i] == 0)
      if (spfa(i)) {
        printf("No\n");
        return 0;
      }
  printf("Yes\n");
  return 0;
}
