#include <bits/stdc++.h>
using namespace std;
template <typename T>
struct UnionFind {
  vector<T> data, dist;
  UnionFind(T n) : data(n, -1), dist(n, 0) {}
  bool unite(T xx, T yy, T d) {
    T x = root(xx);
    T y = root(yy);
    if (x != y) {
      if (data[y] < data[x]) {
        swap(x, y);
        dist[xx] = dist[yy] - d;
      } else {
        dist[yy] = dist[xx] + d;
      }
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  T root(T x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  bool same(T x, T y) { return root(x) == root(y); }
  bool ans(T xx, T yy, T d) { return dist[yy] - dist[xx] == d; }
  T size(T x) { return -data[root(x)]; }
};
int main() {
  int n, q;
  cin >> n >> q;
  UnionFind<long long> uf(n);
  for (int i = 0; i < q; ++i) {
    int l, r, d;
    cin >> l >> r >> d;
    if (uf.same(l, r)) {
      if (!uf.ans(l, r, d)) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      uf.unite(l, r, d);
    }
  }
  cout << "Yes" << endl;
  return 0;
}
