#include <bits/stdc++.h>
using namespace std;
const long long LLINF = (1LL << 60);
const long long INF = (1LL << 30);
const long long MOD = 1000000007;
long long N, M;
long long Pos[100010];
vector<pair<long long, long long> > Lrd[100010];
bool isFinished[100010] = {};
signed main() {
  for (long long i = 0; i < 100010; ++i) {
    Pos[i] = LLINF;
    isFinished[i] = true;
  }
  cin >> N >> M;
  for (long long i = 0; i < M; ++i) {
    long long l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    Lrd[l].push_back({r, d});
    isFinished[l] = false;
  }
  bool isFirst = true;
  for (long long i = 0; i < N; ++i) {
    if (isFinished[i]) {
      continue;
    }
    if (isFirst) {
      Pos[i] = 0;
      isFirst = false;
    }
    queue<long long> que;
    que.push(i);
    while (!que.empty()) {
      long long l = que.front();
      isFinished[l] = true;
      que.pop();
      for (auto& rd : Lrd[l]) {
        long long r = rd.first, d = rd.second;
        que.push(r);
        if (Pos[l] != LLINF && Pos[r] != LLINF) {
          if (Pos[r] - Pos[l] != d) {
            printf("No\n");
            return 0;
          }
        } else if (Pos[l] != LLINF && Pos[r] == LLINF) {
          Pos[r] = l + d;
        } else if (Pos[l] == LLINF && Pos[r] != LLINF) {
          Pos[l] = r - d;
        } else {
          assert(false);
        }
      }
    }
  }
  printf("Yes\n");
  return 0;
}
