#include <bits/stdc++.h>
using namespace std;
struct Edge {
  long long dst, len;
  Edge(long long _dst, long long _len) { dst = _dst, len = _len; }
  Edge() {}
};
long long n, m;
long long cnt[100005];
long long dis[100005];
bool vis[100005];
vector<Edge> edge[100005];
queue<long long> q;
void read() {
  scanf("%lld%lld", &n, &m);
  long long l, r, d;
  for (long long i = 1; i <= m; i++) {
    scanf("%lld%lld%lld", &l, &r, &d);
    edge[l].push_back(Edge(r, d));
    edge[r].push_back(Edge(l, -d));
  }
}
long long get_front() {
  long long x = q.front();
  q.pop(), vis[x] = false;
  return x;
}
void insert(long long x) {
  cnt[x]++;
  if (vis[x]) return;
  q.push(x), vis[x] = true;
}
bool spfa(long long s) {
  dis[s] = 0, insert(s);
  while (!q.empty()) {
    long long x = get_front();
    for (long long i = 0; i < edge[x].size(); i++) {
      Edge temp = edge[x][i];
      if (dis[temp.dst] > dis[x] + temp.len) {
        dis[temp.dst] = dis[x] + temp.len;
        insert(temp.dst);
        if (cnt[temp.dst] > n) return false;
      }
    }
  }
  return true;
}
void work() {
  memset(dis, 0x3f, sizeof(dis));
  for (long long i = 1; i <= n; i++) {
    if (dis[i] > 100000000000000ll) {
      if (!spfa(i)) {
        printf("No\n");
        return;
      }
    }
  }
  printf("Yes\n");
}
signed main() {
  read();
  work();
}
