#include <bits/stdc++.h>
using namespace std;
template <typename T>
class WeightedUnionFind {
 private:
  std::vector<int> par;
  std::vector<int> rnk;
  std::vector<T> diff;

 public:
  WeightedUnionFind(int n) : par(n), rnk(n), diff(n) {
    for (int i = 0; i < n; i++) {
      par[i] = i;
      rnk[i] = 0;
      diff[i] = 0;
    }
  }
  T weight(int x) {
    find(x);
    return diff[x];
  }
  int find(int x) {
    if (par[x] == x)
      return x;
    else
      return find(par[x]);
  }
  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 (rnk[x] < rnk[y]) {
      swap(x, y);
      w = -w;
    }
    par[x] = y;
    if (rnk[x] == rnk[y]) rnk[x]++;
    diff[y] = w;
  }
  bool same(int x, int y) { return find(x) == find(y); }
};
int n, m;
int main() {
  cin >> n >> m;
  WeightedUnionFind<long long> wun(n);
  int l, r;
  long long d;
  for (int i = (0); i < (m); ++i) {
    cin >> l >> r >> d;
    l--;
    r--;
    if (wun.same(l, r) && d != (wun.weight(r) - wun.weight(l))) {
      cout << "No" << endl;
      return 0;
    }
    wun.unite(l, r, d);
  }
  cout << "Yes" << endl;
  return 0;
}
