#include <bits/stdc++.h>
using namespace std;
bool dfs(vector<long long>& o, long long node,
         vector<vector<pair<long long, long long> > > r, vector<bool>& used) {
  int s = r[node].size();
  if (s == NULL) {
    s = 0;
  }
  for (int i = 0; i < s; i++) {
    if (used[r[node][i].first]) {
      if (o[r[node][i].first] == o[node] + r[node][i].second) {
        continue;
      } else {
        return false;
      }
    } else {
      used[r[node][i].first] = true;
      o[r[node][i].first] = o[node] + r[node][i].second;
      if (dfs(o, r[node][i].first, r, used)) {
        continue;
      } else {
        return false;
      }
    }
  }
  return true;
}
void solve(long long N, long long M, vector<long long> L, vector<long long> R,
           vector<long long> D) {
  vector<long long> o(N);
  vector<bool> used(N, false);
  vector<vector<pair<long long, long long> > > r(
      N, vector<pair<long long, long long> >());
  for (int i = 0; i < M; i++) {
    r[L[i] - 1].push_back(make_pair(R[i] - 1, D[i]));
    r[R[i] - 1].push_back(make_pair(L[i] - 1, -D[i]));
  }
  bool flag = true;
  for (int i = 0; i < N; i++) {
    if (used[i]) {
      continue;
    }
    used[i] = true;
    o[i] = 0;
    if (dfs(o, i, r, used)) {
      continue;
    } else {
      flag = false;
    }
  }
  if (flag) {
    long long minx = *min_element(o.begin(), o.end());
    long long maxx = *max_element(o.begin(), o.end());
    if (maxx - minx <= 1000000000) {
      std::cout << "Yes" << std::endl;
    } else {
      std::cout << "No" << std::endl;
    }
  } else {
    std::cout << "No" << std::endl;
  }
}
int main() {
  struct timeval start, end;
  long long span;
  gettimeofday(&start, NULL);
  long long M;
  long long N;
  scanf("%lld", &N);
  scanf("%lld", &M);
  vector<long long> D(M - 1 + 1);
  vector<long long> R(M - 1 + 1);
  vector<long long> L(M - 1 + 1);
  for (int i = 0; i <= M - 1; i++) {
    scanf("%lld", &L[i]);
    scanf("%lld", &R[i]);
    scanf("%lld", &D[i]);
  }
  solve(N, M, L, R, D);
  gettimeofday(&end, NULL);
  span =
      (end.tv_sec - start.tv_sec) * 1000000LL + (end.tv_usec - start.tv_usec);
  std::cerr << "--Total Time: " << span / 1000 << "ms" << endl;
  return 0;
}
