#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
inline void chmin(T &t, U f) {
  if (t > f) t = f;
}
template <class T, class U>
inline void chmax(T &t, U f) {
  if (t < f) t = f;
}
int n, m, v, i;
class UnionFind {
 public:
  vector<int> par, rank, sizes;
  vector<long long> ws;
  UnionFind(int sz) : par(sz), rank(sz, 0), sizes(sz, 1), ws(sz) {
    for (int i = (int)(0); i < (int)(sz); i++) par[i] = i;
  }
  int find(int x) {
    if (par[x] == x)
      return x;
    else {
      ws[x] += ws[par[x]];
      return par[x] = find(par[x]);
    }
  }
  long long weight(int x) {
    find(x);
    return ws[x];
  }
  void unite(int x, int y, int w) {
    w += weight(x);
    w -= weight(y);
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) swap(x, y);
    w -= w;
    rank[x] += rank[y];
    par[x] = y;
    ws[y] = w;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return sizes[find(x)]; }
  long long diff(int x, int y) { return weight(y) - weight(x); }
};
signed main() {
  long long n, m;
  cin >> n >> m;
  UnionFind wuf(n + 1);
  for (long long i = 0; i < m; i++) {
    long long l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    if (wuf.same(l, r)) {
      if (wuf.diff(l, r) != d) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      wuf.unite(l, r, d);
    }
  }
  cout << "Yes" << endl;
  return 0;
}
