#include <bits/stdc++.h>
#pragma target("avx")
using ll = int_fast64_t;
using P = std::pair<ll, ll>;
using V = std::vector<ll>;
template <typename T>
using pq = std::priority_queue<T>;
template <typename T>
using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int main() {
  ll n, m;
  scanf("%ld %ld", &n, &m);
  std::vector<P> links[n];
  while (m--) {
    ll l, r, d;
    scanf("%ld %ld %ld", &l, &r, &d);
    links[l - 1].emplace_back(r - 1, d);
    links[r - 1].emplace_back(l - 1, -d);
  }
  bool ok = true;
  V coo(n, -1), used(n, 0);
  for (ll i = 0; i < n; i++) {
    if (used[i]) continue;
    std::queue<P> que;
    que.emplace(i, 0);
    while (!que.empty()) {
      P p = que.front();
      que.pop();
      used[p.first] = true;
      coo[p.first] = p.second;
      for (P to : links[p.first]) {
        if (!used[to.first])
          que.emplace(to.first, p.second + to.second);
        else if (coo[to.first] != p.second + to.second)
          ok = false;
      }
    }
  }
  if (ok)
    puts("Yes");
  else
    puts("No");
  return 0;
}
