#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100005;
template <typename T>
class Weighted_UnionFind {
 public:
  vector<int> par, sz;
  vector<T> wd;
  int V;
  Weighted_UnionFind(int node_size) {
    V = node_size;
    par.resize(V), wd.resize(V, 0), sz.resize(V, 1);
    for (int i = 0; i < (int)(V); ++i) {
      par[i] = i;
    }
  }
  int find(int x) {
    if (par[x] == x) {
      return x;
    } else {
      int parent = find(par[x]);
      wd[x] += wd[par[x]];
      return par[x] = parent;
    }
  }
  T weight(int x) {
    find(x);
    return wd[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 (sz[x] < sz[y]) {
      swap(x, y);
      w = -w;
    }
    sz[x] += sz[y];
    par[y] = x;
    wd[y] = w;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  T diff(int x, int y) { return weight(y) - weight(x); }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  Weighted_UnionFind<int> wu(n);
  for (int i = 0; i < (int)(m); ++i) {
    int l, r, d;
    cin >> l >> r >> d;
    --l, --r;
    if (wu.same(l, r)) {
      if (wu.diff(l, r) != d) {
        cout << l << " " << r << "\n";
        cout << "No\n";
        return 0;
      }
    } else {
      wu.unite(l, r, d);
    }
  }
  cout << "Yes\n";
  return 0;
}
