#include <bits/stdc++.h>
using namespace std;
const int inf = 1001001000;
const long long INF = 1LL << 60;
const int MOD = (int)1e9 + 7;
class UnionFind {
  vector<long long> par;
  vector<long long> r_size;

 public:
  UnionFind(long long N) : par(N), r_size(N) {
    for (int i = 0; i < N; ++i) {
      par[i] = i;
      r_size[i] = 1;
    }
  }
  void init(long long N) {
    par.resize(N);
    r_size.resize(N);
    for (int i = 0; i < N; ++i) {
      par[i] = i;
      r_size[i] = 1;
    }
  }
  long long find(long long x) {
    if (par[x] == x) return x;
    return par[x] = find(par[x]);
  }
  void unite(long long x, long long y) {
    long long rx = find(x);
    long long ry = find(y);
    if (rx == ry) return;
    if (r_size[rx] < r_size[ry]) swap(rx, ry);
    r_size[rx] += r_size[ry];
    par[ry] = rx;
  }
  bool same(long long x, long long y) {
    long long ry = find(x);
    long long rx = find(y);
    return rx == ry;
  }
  long long el_size(long long x) { return r_size[find(x)]; }
};
int main() {
  int N, M, l, r, d;
  cin >> N >> M;
  vector<int> dist(N, 0);
  UnionFind uf(N);
  bool ans = true;
  for (int _ = 0; _ < M; ++_) {
    cin >> l >> r >> d;
    --l;
    --r;
    if (r < l) {
      swap(r, l);
      d = -d;
    }
    if (uf.same(r, l) && dist[r] - dist[l] != d) {
      ans = false;
      break;
    }
    uf.unite(l, r);
    dist[r] = dist[l] + d;
  }
  cout << ((ans) ? "Yes" : "No") << endl;
  return 0;
}
