#include <bits/stdc++.h>
using namespace std;
int N, M;
struct {
  int s;
  int d;
} x[100000 + 1]{};
map<int, list<int>> info;
void Failed(bool condition) {
  if (condition) {
    cout << "No" << endl;
    exit(0);
  }
}
int main(int argc, char *argv[]) {
  cin >> N >> M;
  int l, r;
  int d;
  for (int i = 0; i < M; i++) {
    cin >> l >> r >> d;
    if (x[l].s == 0 && x[r].s == 0) {
      info[l] = {l, r};
      x[l] = {l, 0};
      x[r] = {l, d};
    } else if (x[l].s != 0 && x[r].s == 0) {
      x[r] = {x[l].s, d + x[l].d};
      auto &v = info[x[l].s];
      v.push_back(r);
    } else if (x[l].s == 0 && x[r].s != 0) {
      x[l] = {x[r].s, x[r].d - d};
      auto &v = info[x[r].s];
      v.push_back(l);
    } else if (x[l].s != x[r].s) {
      int ls = x[l].s, rs = x[r].s;
      auto &vl = info[ls];
      auto &vr = info[rs];
      int delta = x[l].d + d - x[r].d;
      for (auto j : vr) {
        x[j] = {ls, delta + x[j].d};
        vl.push_back(j);
      }
      info.erase(rs);
    } else {
      Failed(x[r].d - x[l].d != d);
    }
  }
  cout << "Yes" << endl;
  return 0;
}
