#include <bits/stdc++.h>
using namespace std;
map<long long, long long> t;
struct UnionFind {
  int par[100001], rank[100001];
  void init(int n) {
    for (int i = 0; i < n; i++) {
      par[i] = i;
      rank[i] = 0;
    }
  }
  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 (rank[x] < rank[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if (rank[x] == rank[y]) rank[x]++;
    }
  }
  bool same(int x, int y) { return (find(x) == find(y)); }
};
int main() {
  long long n, m, l, r, d;
  cin >> n >> m;
  UnionFind uf;
  uf.init(n);
  for (int i = (0); i < (m); ++i) {
    cin >> l >> r >> d;
    --l, --r;
    if (t.count(l) == 0 && t.count(r) == 0)
      t[l] = 0, t[r] = d, uf.unite(l, r);
    else if (t.count(l) > 0 && t.count(r) == 0)
      t[r] = t[l] + d, uf.unite(l, r);
    else if (t.count(l) == 0 && t.count(r) > 0)
      t[l] = t[r] - d, uf.unite(l, r);
    else {
      if (t[r] - t[l] != d && uf.same(l, r)) {
        cout << "No" << endl;
        return 0;
      } else if (!uf.same(l, r)) {
        long long sub = t[r] - t[l];
        for (auto it : t) {
          if (uf.same(r, it.first)) {
            t[it.first] = t[it.first] - sub + d;
            uf.unite(l, it.first);
          }
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
