#include <bits/stdc++.h>
using namespace std;
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
struct edge {
  int to, cost;
};
typedef pair<int, int> P;
const long long INF = LONG_LONG_MAX;
const int MAX_V = 1e5 + 3;
int V;
vector<edge> G[MAX_V];
long long d[MAX_V];
bool dijkstra(int s) {
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d, d + V, INF);
  d[s] = 0;
  que.push(P(0, s));
  while (!que.empty()) {
    P p = que.top();
    que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (long long i = (0); i < (G[v].size()); ++i) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        if (d[e.to] != INF) return false;
        d[e.to] = d[v] + e.cost;
        que.push(P(d[e.to], e.to));
      }
    }
  }
  return true;
}
struct UnionFind {
  vector<int> par;
  vector<int> sizes;
  vector<int> rnk;
  UnionFind() {}
  UnionFind(int n) {
    par.resize(n);
    rnk.resize(n, 0);
    sizes.resize(n, 1);
    for (long long i = (0); i < (n); ++i) par[i] = i;
  }
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rnk[x] < rnk[y]) {
      par[x] = y;
      sizes[y] += sizes[x];
    } else {
      par[y] = x;
      sizes[x] += sizes[y];
      if (rnk[x] == rnk[y]) rnk[x]++;
    }
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return sizes[find(x)]; }
};
bool st[MAX_V];
int main() {
  int N, M;
  cin >> N >> M;
  V = N;
  UnionFind uf(N);
  for (long long i = (0); i < (M); ++i) {
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    edge e{r, d};
    uf.unite(r, l);
    G[l].emplace_back(e);
  }
  memset((st), 0, sizeof(st));
  for (long long i = (0); i < (N); ++i) {
    int t = uf.find(i);
    if (st[t] == 0 && uf.size(t) > 1) {
      st[t] = 1;
      if (!dijkstra(t)) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
