#include <bits/stdc++.h>
using namespace std;
std::mt19937 mt((long long)time(0));
long long dx[4] = {0, 1, 0, -1};
long long dy[4] = {1, 0, -1, 0};
long long L[200001], R[200001], D[200001];
long long ma[100002];
signed main() {
  long long N, M;
  cin >> N >> M;
  for (long long i = 0; i < 100002; i++) {
    ma[i] = 9223372036854775807 / 2;
  }
  for (long long i = 0; i < M; i++) {
    cin >> L[i] >> R[i] >> D[i];
  }
  long long cnt = 0;
  for (long long i = 0; i < M; i++) {
    if (ma[L[i]] == 9223372036854775807 / 2 &&
        ma[R[i]] == 9223372036854775807 / 2) {
      ma[L[i]] = 0;
      ma[R[i]] = D[i];
    } else if (ma[L[i]] != 9223372036854775807 / 2 &&
               ma[R[i]] == 9223372036854775807 / 2) {
      ma[R[i]] = ma[L[i]] + D[i];
    } else if (ma[R[i]] != 9223372036854775807 / 2 &&
               ma[L[i]] == 9223372036854775807 / 2) {
      ma[L[i]] = ma[R[i]] - D[i];
    } else {
      if (ma[R[i]] - ma[L[i]] != D[i]) cnt++;
    }
  }
  if (cnt == 0)
    cout << "Yes\n";
  else
    cout << "No\n";
  return 0;
}
