#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const string YES = "Yes";
const string NO = "No";
void solve(long long N, long long M, std::vector<long long> L,
           std::vector<long long> R, std::vector<long long> D) {
  vector<long long> X(N, -1);
  for (int i = 0; i < M; i++) {
    L[i]--;
    R[i]--;
    if (X[L[i]] == -1 && X[R[i]] == -1) {
      X[L[i]] = 0;
      X[R[i]] = D[i];
    } else if (X[L[i]] == -1) {
      X[L[i]] = X[R[i]] - D[i];
    } else if (X[R[i]] == -1) {
      X[R[i]] = X[L[i]] + D[i];
    } else {
      if (X[R[i]] - X[L[i]] != D[i]) {
        cout << NO << endl;
        return;
      }
    }
  }
  cout << YES << endl;
}
int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> L(M);
  std::vector<long long> R(M);
  std::vector<long long> D(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &L[i]);
    scanf("%lld", &R[i]);
    scanf("%lld", &D[i]);
  }
  solve(N, M, std::move(L), std::move(R), std::move(D));
  return 0;
}
