#include <bits/stdc++.h>
using namespace std;
using TUP = tuple<int, int, int>;
const long long inf = 1e18;
int main() {
  int n, m, l, r, d;
  cin >> n >> m;
  vector<TUP> info(m);
  for (int i = 0; i < m; i++) {
    cin >> l >> r >> d;
    l--;
    r--;
    if (l > r) {
      swap(l, r);
      d *= -1;
    }
    info[i] = make_tuple(l, r, d);
  }
  sort(info.begin(), info.end());
  vector<long long> place(n, inf);
  vector<TUP> unused;
  while (!info.empty()) {
    place[get<0>(info[0])] = 0;
    for (auto t : info) {
      l = get<0>(t);
      r = get<1>(t);
      d = get<2>(t);
      if (place[l] != inf && place[r] != inf) {
        if (place[r] - place[l] != d) {
          cout << "No" << endl;
          return 0;
        }
      } else if (place[l] != inf) {
        place[r] = place[l] + d;
      } else if (place[r] != inf) {
        place[l] = place[r] - d;
      } else {
        unused.emplace_back(t);
      }
    }
    info = unused;
  }
  cout << "Yes" << endl;
  return 0;
}
