#include <bits/stdc++.h>
using ll = long long;
template <typename Group>
class PotentialUnionFind {
 public:
  using value_t = typename Group::value_t;
  using size_t = std::size_t;

 private:
  size_t group;
  std::vector<size_t> par, sz;
  std::vector<value_t> df;
  value_t fold_to_root(size_t x) {
    value_t ret = Group::id;
    while (par[x] != x) {
      df[x] = Group::op(df[x], df[par[x]]);
      par[x] = par[par[x]];
      ret = Group::op(ret, df[x]);
      x = par[x];
    }
    return ret;
  }

 public:
  PotentialUnionFind(size_t n = 0)
      : group(n), par(n), sz(n, 1), df(n, Group::id) {
    std::iota(par.begin(), par.end(), 0);
  }
  size_t root(size_t x) {
    while (par[x] != x) {
      df[x] = Group::op(df[x], df[par[x]]);
      par[x] = par[par[x]];
      x = par[x];
    }
    return x;
  }
  bool same(size_t a, size_t b) { return root(a) == root(b); }
  size_t size() { return par.size(); }
  size_t groups() { return group; }
  size_t group_size(size_t x) { return sz[root(x)]; }
  bool unite(size_t a, size_t b, value_t value) {
    a = root(a);
    b = root(b);
    if (a == b) return false;
    group--;
    if (sz[a] < sz[b]) {
      std::swap(a, b);
      value = Group::inv(value);
    }
    sz[a] += sz[b];
    value = Group::op(value, fold_to_root(a));
    value = Group::op(Group::inv(fold_to_root(b)), value);
    df[b] = value;
    par[b] = a;
    return true;
  }
  value_t diff(size_t a, size_t b) {
    assert(same(a, b));
    return Group::op(fold_to_root(b), Group::inv(fold_to_root(a)));
  }
};
struct Group {
  using value_t = ll;
  static constexpr value_t id = 0;
  static constexpr value_t op(value_t a, value_t b) { return a + b; }
  static constexpr value_t inv(value_t a) { return -a; }
};
int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  ll n, m;
  std::cin >> n >> m;
  PotentialUnionFind<Group> uni(n);
  while (m--) {
    ll l, r, d;
    std::cin >> l >> r >> d;
    l--;
    r--;
    if (uni.same(l, r)) {
      if (uni.diff(r, l) != d) {
        std::cout << "No\n";
        return 0;
      }
    } else {
      uni.unite(r, l, d);
    }
  }
  std::cout << "Yes\n";
  return 0;
}
