#include <bits/stdc++.h>
using namespace std;
struct UnionFind {
  vector<int> r;
  vector<int> d;
  UnionFind(int N) {
    r = vector<int>(N, -1);
    d = vector<int>(N, 0);
  }
  int root(int x) {
    if (r[x] < 0) return x;
    return r[x] = root(r[x]);
  }
  bool unite(int x, int y, int dis) {
    if ((d[x] != 0 && d[y] != 0) && d[y] != d[x] + dis) return false;
    if (d[x] == 0) d[x] = 1;
    d[y] = d[x] + dis;
    x = root(x);
    y = root(y);
    if (r[x] > r[y]) swap(x, y);
    r[x] += r[y];
    r[y] = x;
    return true;
  }
  int size(int x) { return -r[root(x)]; }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  UnionFind uf = UnionFind(n + 1);
  bool flag = true;
  for (long long i = 0; i < m; ++i) {
    int l, r, d;
    cin >> l >> r >> d;
    if (!uf.unite(l, r, d)) flag = false;
  }
  if (flag)
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}
