#include <bits/stdc++.h>
using namespace std;
int N, M;
struct {
  int s;
  int d;
} x[100000 + 1]{};
map<int, vector<int>> info;
int main(int argc, char *argv[]) {
  cin >> N >> M;
  int l, r, d;
  for (int i = 0; i < M; i++) {
    cin >> l >> r >> d;
    if (x[l].s == 0 && x[r].s == 0) {
      info[l] = {l, d};
      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];
      auto it = lower_bound(
          v.begin(), v.end(), r,
          [](const int &a, const int &b) -> bool { return x[a].d < x[b].d; });
      v.insert(it, 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];
      auto it = lower_bound(
          v.begin(), v.end(), l,
          [](const int &a, const int &b) -> bool { return x[a].d < x[b].d; });
      v.insert(it, l);
    } else if (x[l].s != x[r].s) {
      auto &vl = info[x[l].s];
      auto &vr = info[x[r].s];
      for (auto j : vr) {
        x[j] = {x[l].s, x[r].d + d};
      }
      vector<int> v(vl.size() + vr.size());
      std::merge(
          vl.begin(), vl.end(), vr.begin(), vr.end(), v.begin(),
          [](const int &a, const int &b) -> bool { return x[a].d < x[b].d; });
      info.erase(x[r].s);
      vl = std::move(v);
    } else {
      if (x[r].d - x[l].d != d) {
        cout << "No" << endl;
        exit(0);
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
