#include <bits/stdc++.h>
using namespace std;
struct UFNode {
  UFNode *parent;
  int rank, pos;
  UFNode() : parent(nullptr), rank(0), pos(0) {}
  UFNode &Find() {
    if (parent == nullptr) return *this;
    auto t = &parent->Find();
    pos += parent->pos;
    return *(parent = t);
  }
  int Union(UFNode &n, int d) {
    auto &r = Find(), &nr = n.Find();
    if (&r == &nr) return pos + d == n.pos;
    if (r.rank < nr.rank)
      r.parent = &nr, r.pos = n.pos - d;
    else
      nr.parent = &r, r.rank += r.rank == nr.rank, nr.pos = pos + d;
    return -1;
  }
} u[111111];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int l, r, d;
    scanf("%d%d%d", &l, &r, &d);
    if (!u[l].Union(u[r], d)) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
