#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<bool> v(N, false);
  vector<int> pos(N, 0);
  vector<tuple<int, int, int> > lst(M);
  for (int i = int(0); i < int(M); i++) {
    int L, R, D;
    cin >> L >> R >> D;
    L--;
    R--;
    if (L > R) {
      swap(L, R);
      D = -D;
    }
    lst[i] = make_tuple(L, R, D);
  }
  sort(lst.begin(), lst.end());
  for (int i = int(0); i < int(M); i++) {
    int L = get<0>(lst[i]), R = get<1>(lst[i]), D = get<2>(lst[i]);
    bool ot = false;
    if (v[L] == false && v[R] == false) {
      pos[L] = 0;
      pos[R] = pos[L] + D;
    } else if (v[L] == true && v[R] == false) {
      pos[R] = pos[L] + D;
    } else if (v[L] == false && v[R] == true) {
      pos[L] = pos[R] + D;
    } else {
      if (pos[L] + D != pos[R]) {
        ot = true;
      }
    }
    v[L] = v[R] = true;
    if (ot) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
