#include <bits/stdc++.h>
std::string arc090d(int N, int M, const std::vector<int>& L_,
                    const std::vector<int>& R_, const std::vector<int>& D_) {
  std::vector<int> L(L_), R(R_), D(D_);
  for (int i = 0; i < M; i++) {
    for (int j = i + 1; j < M; j++) {
      if (R[j] == L[i]) {
        int t = R[j];
        R[j] = L[j];
        L[j] = t;
        D[j] = -D[j];
      }
      if (L[j] == L[i]) {
        L[j] = R[i];
        D[j] -= D[i];
      }
      if (L[j] == R[j]) {
        if (D[j]) {
          return "No";
        } else {
          L[j] = L[M - 1];
          R[j] = R[M - 1];
          D[j] = D[M - 1];
          M--;
          j--;
          continue;
        }
      }
      if (L[j] > R[j]) {
        int t = R[j];
        R[j] = L[j];
        L[j] = t;
        D[j] = -D[j];
      }
    }
  }
  return "Yes";
}
int main(int argc, char* argv[]) {
  int N, M;
  std::vector<int> L, R, D;
  std::cin >> N >> M;
  L.resize(M);
  R.resize(M);
  D.resize(M);
  for (int i = 0; i < M; i++) {
    std::cin >> L[i] >> R[i] >> D[i];
  }
  std::cout << arc090d(N, M, L, R, D) << std::endl;
  return 0;
}
