#include <bits/stdc++.h>
using namespace std;
const long long INF = INT64_MAX;
class WeightedUF {
 public:
  long long tsize;
  long long mode;
  vector<long long> par;
  vector<long long> rank;
  vector<long long> w;
  WeightedUF() {}
  WeightedUF(const WeightedUF &wuft) {}
  WeightedUF(long long n, long long m = 0) {
    tsize = n;
    mode = m;
    par.resize(n, -1);
    if (!mode) rank.resize(n, 0);
    w.resize(n, 0);
  }
  long long root(long long x) {
    if (par[x] < 0) {
      return x;
    } else {
      long long r = root(par[x]);
      w[x] += w[par[x]];
      return par[x] = r;
    }
  }
  long long weight(long long x) {
    root(x);
    return w[x];
  }
  long long diff(long long x, long long y) { return weight(y) - weight(x); }
  bool isRoot(long long x) { return root(x) == x; }
  bool isSame(long long x, long long y) { return root(x) == root(y); }
  void unite(long long x, long long y, long long _w) {
    _w += weight(x);
    _w -= weight(y);
    x = root(x);
    y = root(y);
    if (x == y) return;
    if (mode) {
      par[x] += par[y];
      par[y] = x;
    } else {
      if (rank[x] < rank[y]) {
        par[y] += par[x];
        par[x] = y;
        w[x] = -_w;
      } else {
        par[x] += par[y];
        par[y] = x;
        if (rank[x] == rank[y]) rank[x]++;
        w[y] = _w;
      }
    }
  }
  long long size(long long x) { return -par[root(x)]; }
};
int main() {
  long long N, M;
  cin >> N >> M;
  vector<long long> L(M), R(M), D(M);
  for (int i = 0; i < M; i++) {
    cin >> L[i] >> R[i] >> D[i];
  }
  WeightedUF uf(N);
  for (int i = 0; i < M; i++) {
    if (uf.isSame(L[i], R[i])) {
      if (uf.diff(L[i], R[i]) != D[i]) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      uf.unite(L[i], R[i], D[i]);
    }
  }
  cout << "Yes" << endl;
  return 0;
}
