#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_l[100010];
vector<pair<long long, long long> > Lrd_r[100010];
bool isFinished_l[100010] = {};
bool isFinished_r[100010] = {};
signed main() {
  for (long long i = 0; i < 100010; ++i) {
    Pos[i] = LLINF;
    isFinished_l[i] = true;
    isFinished_r[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[l].push_back({r, d});
    Lrd_r[r].push_back({l, d});
    isFinished_l[l] = false;
    isFinished_r[r] = false;
  }
  bool isFirst = true;
  long long left_max = 0, right_max = 0;
  for (long long loop = 0; loop < 10; ++loop) {
    for (long long i = 0; i < N; ++i) {
      if (isFinished_l[i] && isFinished_r[i]) {
        continue;
      }
      if (isFirst) {
        Pos[i] = 0;
        isFirst = false;
      }
      queue<long long> que;
      que.push(i);
      while (!que.empty()) {
        long long l = que.front();
        que.pop();
        if (isFinished_l[l]) {
          continue;
        }
        for (auto& rd : Lrd_l[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] = Pos[l] + d;
            right_max = max(right_max, Pos[r]);
          } else if (Pos[l] == LLINF && Pos[r] != LLINF) {
            Pos[l] = Pos[r] - d;
            left_max = min(left_max, Pos[l]);
          }
        }
        if (Pos[l] != LLINF) {
          isFinished_l[l] = true;
        }
      }
      que.push(i);
      while (!que.empty()) {
        long long r = que.front();
        que.pop();
        if (isFinished_r[r]) {
          continue;
        }
        for (auto& ld : Lrd_r[r]) {
          long long l = ld.first, d = ld.second;
          que.push(l);
          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] = Pos[l] + d;
            right_max = max(right_max, Pos[r]);
          } else if (Pos[l] == LLINF && Pos[r] != LLINF) {
            Pos[l] = Pos[r] - d;
            left_max = min(left_max, Pos[l]);
          }
        }
        if (Pos[r] != LLINF) {
          isFinished_r[r] = true;
        }
      }
    }
  }
  if (right_max - left_max > 1000000000ll) {
    printf("No\n");
    ;
    return 0;
  }
  printf("Yes\n");
  return 0;
}
