#include <bits/stdc++.h>
using namespace std;
struct st {
  int L, R, D;
};
int main() {
  int N, M;
  cin >> N >> M;
  vector<st> S(M);
  for (int i = 0; i < M; i++) {
    cin >> S[i].L >> S[i].R >> S[i].D;
    if (S[i].L > S[i].R) {
      swap(S[i].L, S[i].R);
      S[i].D *= -1;
    }
  }
  sort(S.begin(), S.end(),
       [&](const st& lsh, const st& rhs) { return (lsh.L < rhs.L); });
  const int def = 10000;
  vector<long long> pos(N + 1, -1);
  for (int i = 0; i < M; i++) {
    if (pos[S[i].L] == -1 && pos[S[i].R] == -1) {
      pos[S[i].L] = def;
      pos[S[i].R] = def + S[i].D;
    } else if (pos[S[i].L] == -1) {
      pos[S[i].L] = pos[S[i].R] - S[i].D;
    } else if (pos[S[i].R] == -1) {
      pos[S[i].R] = pos[S[i].L] + S[i].D;
    } else {
      if (pos[S[i].R] - pos[S[i].L] != S[i].D) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}
