#include <bits/stdc++.h>
const int MAX_N = 100050;
const int MAX_M = 200050;
int l_in[MAX_M], r_in[MAX_M], d_in[MAX_M];
int N, M;
int par[MAX_N];
long long loc[MAX_N];
long long root_max_dist[MAX_N][2];
int root(int x) {
  if (par[x] == x) {
    return x;
  }
  loc[x] += loc[par[x]];
  par[x] = root(par[x]);
  return par[x];
}
bool unite(int x, int y, long long d) {
  int rx = root(x);
  int ry = root(y);
  if (rx == ry) {
    if (loc[y] - loc[x] == d) {
      return true;
    } else {
      return false;
    }
  } else {
    par[rx] = ry;
    loc[rx] = -d;
    return true;
  }
}
bool same(int x, int y) {
  int rx = root(x);
  int ry = root(y);
  return rx == ry;
}
int main(int argc, char **argv) {
  std::cin >> N >> M;
  for (int i = 1; i <= M; i++) {
    std::cin >> l_in[i] >> r_in[i] >> d_in[i];
  }
  for (int i = 1; i <= N; i++) {
    par[i] = i;
    loc[i] = 0;
    root_max_dist[i][0] = 0;
    root_max_dist[i][1] = 0;
  }
  for (int i = 1; i <= M; i++) {
    if (!unite(l_in[i], r_in[i], d_in[i])) {
      std::cout << "No" << std::endl;
      return 0;
    }
  }
  for (int i = 1; i <= N; i++) {
    const int r = root(i);
    root_max_dist[r][0] = std::min(root_max_dist[r][0], loc[i]);
    root_max_dist[r][1] = std::max(root_max_dist[r][1], loc[i]);
    if (root_max_dist[r][1] - root_max_dist[r][0] > 1000000000) {
      std::cout << "No" << std::endl;
      return 0;
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}
