#include <bits/stdc++.h>
using namespace std;
class UnionFind {
  vector<int> p;

 public:
  UnionFind(int n) {
    p = vector<int>(n);
    for (int i = 0; i < n; i++) {
      p[i] = i;
    }
    return;
  }
  void printState() {
    if (0) {
      cout << "---" << endl;
      for (int i = 0; i < p.size(); i++) {
        printf("%dの親は%d\n", i, p[i]);
      }
      cout << "---" << endl;
    }
  }
  int find(int x) {
    if (p[x] == x) return x;
    return p[x] = find(p[x]);
  }
  void unite(int x, int y) { p[find(x)] = p[find(y)]; }
  bool same(int x, int y) { return find(x) == find(y); }
};
class Dijkstra {
 public:
  struct edge {
    long long int to, cost;
  };
  typedef pair<long long int, long long int> P;
  int V;
  vector<vector<edge> > G;
  vector<long long int> d;
  Dijkstra(int N) {
    V = N;
    G = vector<vector<edge> >(N);
    d = vector<long long int>(N);
  };
  bool dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d.begin(), d.end(), (long long int)5e15);
    d[s] = 0;
    que.push(P(0, s));
    while (!que.empty()) {
      P p = que.top();
      que.pop();
      long long int v = p.second;
      if (d[v] < p.first) continue;
      for (int i = 0; i < G[v].size(); i++) {
        edge e = G[v][i];
        if (d[e.to] < d[v] + e.cost) return false;
        if (d[e.to] > d[v] + e.cost &&
            !(d[e.to] == (long long int)5e15 && d[v] == (long long int)5e15)) {
          if (d[e.to] != (long long int)5e15) return false;
          d[e.to] = d[v] + e.cost;
          que.push(P(d[e.to], e.to));
        }
      }
    }
    return true;
  }
  void addEdge(int from, int to, int cost) {
    edge e;
    e.to = to;
    e.cost = cost;
    G[from].push_back(e);
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  UnionFind uf(N);
  Dijkstra dij(N);
  for (int i = int(0); i < int(M); i++) {
    int L, R, D;
    cin >> L >> R >> D;
    L--;
    R--;
    uf.unite(L, R);
    dij.addEdge(L, R, D);
  }
  set<int> apr;
  for (int i = int(0); i < int(N); i++) {
    if (apr.find(uf.find(i)) == apr.end()) {
      apr.insert(uf.find(i));
      if (!dij.dijkstra(i)) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
