#include <bits/stdc++.h>
struct edge {
  int to;
  long long cost;
};
int n, m;
std::vector<edge> e[100005];
long long v[100005];
bool visited[100005];
bool dfs(int pos) {
  visited[pos] = true;
  for (size_t i = 0; i < e[pos].size(); ++i) {
    auto next = e[pos][i].to;
    if (visited[next]) {
      if (v[pos] + e[pos][i].cost != v[next]) return false;
    } else {
      v[next] = v[pos] + e[pos][i].cost;
      if (!dfs(next)) return false;
    }
  }
  return true;
}
int main() {
  std::cin >> n >> m;
  int start;
  for (int i = 0; i < m; ++i) {
    int l, r, d;
    std::cin >> l >> r >> d;
    --l, --r;
    if (i == 0) start = l;
    edge tmp;
    tmp.to = r, tmp.cost = d;
    e[l].emplace_back(tmp);
    tmp.to = l, tmp.cost = -d;
    e[r].emplace_back(tmp);
  }
  if (m == 0 || dfs(start))
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;
  return 0;
}
