#include <bits/stdc++.h>
using namespace std;
template <class Node>
struct UnionFind {
  vector<int> par;
  vector<int> rank;
  vector<Node> nodes;
  function<void(Node&, Node&)> f;
  UnionFind(const vector<Node>& init, function<void(Node&, Node&)> func)
      : par(init.size(), 0), rank(init.size(), 0), nodes(init), f(func) {
    for (int i = 0; i < init.size(); i++) {
      par[i] = i;
    }
  }
  int root(int x) { return par[x] == x ? x : par[x] = root(par[x]); }
  int unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return 0;
    int r, c;
    int res = 1;
    if (rank[x] < rank[y]) {
      par[x] = y;
      r = y;
      c = x;
      res = -1;
    } else {
      par[y] = x;
      r = x;
      c = y;
      if (rank[x] == rank[y]) rank[x]++;
      res = 1;
    }
    f(nodes[r], nodes[c]);
    return res;
  }
  bool same(int x, int y) { return root(x) == root(y); }
  Node value(int x) { return nodes[x]; }
};
template <class Weight = long long>
struct WeightedUnionFind : public UnionFind<Weight> {
  WeightedUnionFind(int size)
      : UnionFind<Weight>(vector<Weight>(size, 0),
                          [](Weight& rn, Weight& cn) {}) {}
  int root(int x) {
    if (x == this->par[x]) return x;
    int parent = root(this->par[x]);
    this->nodes[x] += this->nodes[this->par[x]];
    return this->par[x] = parent;
  }
  int unite(int x, int y, Weight w) {
    int res = UnionFind<Weight>::unite(x, y);
    w = w + weight(x) - weight(y);
    if (res == 0) return 0;
    if (res == -1) {
      w = -w;
      swap(x, y);
    }
    this->nodes[y] = w;
    return res;
  }
  Weight weight(int x) {
    root(x);
    return this->nodes[x];
  }
  pair<bool, Weight> diff(int x, int y) {
    if (!this->same(x, y)) return {false, 0};
    return {true, weight(x) - weight(y)};
  }
};
using namespace std;
using i64 = long long;
int N, M;
int main() {
  cin >> N >> M;
  WeightedUnionFind<> uf(N + 1);
  for (int(i) = (0); (i) <= (M - 1); (i)++) {
    int l, r, d;
    cin >> l >> r >> d;
    auto p = uf.diff(r, l);
    if (!p.first) {
      uf.unite(l, r, d);
    } else if (p.second == d) {
      continue;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}
