#include <bits/stdc++.h>
using namespace std;
const long long MOD = pow(10, 9) + 7;
long long mod(long long A, long long M) { return (A % M + M) % M; }
const long long INF = 1LL << 60;
template <class T>
bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
long long divCeil(long long A, long long B) { return (A + (B - 1)) / B; }
long long myctoi(char C) { return C - 48; }
char myitoc(long long N) { return '0' + N; }
template <class A>
class unionfind {
 public:
  vector<long long> parent;
  vector<long long> rank;
  vector<A> diffw;
  unionfind(long long N, A U = 0) {
    parent = vector<long long>(N, -1);
    rank = vector<long long>(N, 0);
    diffw = vector<long long>(N, U);
  }
  long long root(long long X) {
    if (parent.at(X) < 0) return X;
    diffw.at(X) += diffw.at(parent.at(X));
    return parent.at(X) = root(parent.at(X));
  }
  long long size(long long X) { return -parent.at(root(X)); }
  A weight(long long X) {
    root(X);
    return diffw.at(X);
  }
  A diff(long long X, long long Y) { return weight(Y) - weight(X); }
  bool same(long long X, long long Y) { return (root(X) == root(Y)); }
  bool unite(long long X, long long Y, A W) {
    W += weight(X);
    W -= weight(Y);
    X = root(X);
    Y = root(Y);
    if (X == Y) return false;
    if (rank.at(X) < rank.at(Y)) {
      swap(X, Y);
      W = -W;
    }
    if (rank.at(X) == rank.at(Y)) parent.at(X)++;
    parent.at(X) += parent.at(Y);
    parent.at(Y) = X;
    diffw.at(Y) = W;
    return true;
  }
};
signed main() {
  long long N, M;
  cin >> N >> M;
  unionfind<long long> uf(N);
  for (long long i = 0; i < M; i++) {
    long long L, R, D;
    cin >> L >> R >> D;
    L--;
    R--;
    if (uf.same(L, R)) {
      if (uf.diff(L, R) != D) {
        cout << "No" << endl;
        return 0;
      }
    } else
      uf.unite(L, R, D);
  }
  cout << "Yes" << endl;
}
