#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <typename T>
struct WeightedUnionFind {
  int n;
  T d;
  vector<int> r, p;
  vector<T> ws;
  WeightedUnionFind() {}
  WeightedUnionFind(int sz, T d_) : n(sz), d(d_), r(n, 1), p(n), ws(n, d) {
    iota(p.begin(), p.end(), 0);
  }
  int find(int x) {
    if (x == p[x]) {
      return x;
    } else {
      int t = find(p[x]);
      ws[x] += ws[p[x]];
      return p[x] = t;
    }
  }
  T weight(int x) {
    find(x);
    return ws[x];
  }
  bool same(int x, int y) { return find(x) == find(y); }
  void unite(int x, int y, T w) {
    w += weight(x);
    w -= weight(y);
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (r[x] < r[y]) swap(x, y), w = -w;
    r[x] += r[y];
    p[y] = x;
    ws[y] = w;
  }
  T diff(int x, int y) { return weight(y) - weight(x); }
};
int main() {
  int n, m;
  cin >> n >> m;
  WeightedUnionFind<ll> k(n + 1, 0);
  for (int i = 0; i < (int)(m); ++i) {
    int l, r, d;
    cin >> l >> r >> d;
    if (k.same(l, r) and k.diff(l, r) != d) {
      puts("No");
      return 0;
    }
    k.unite(l, r, d);
  }
  puts("Yes");
  return 0;
}
