#include <bits/stdc++.h>
using namespace std;
inline bool check(long long l, long long r, long long d,
                  map<long long, long long> &dic) {
  if (dic.count(l)) {
    if (dic.count(r)) {
      if (dic[r] - dic[l] != d) {
        return false;
      }
    } else {
      dic[r] = dic[l] + d;
    }
  } else if (dic.count(r)) {
    dic[l] = dic[r] - d;
  } else {
    dic[l] = 0;
    dic[r] = d;
  }
  return true;
}
long long N, M, LS[200010], RS[200010], DS[200010];
int main(int argc, char const *argv[]) {
  cin >> N >> M;
  multimap<long long, long long> idx;
  for (int i = 0; i < M; ++i) {
    cin >> LS[i] >> RS[i] >> DS[i];
    idx.insert(make_pair(LS[i], i));
    idx.insert(make_pair(RS[i], i));
  }
  map<long long, long long> dic;
  set<long long> used;
  for (int i = 0; i < M; ++i) {
    if (used.count(i)) continue;
    used.insert(i);
    if (!check(LS[i], RS[i], DS[i], dic)) {
      cout << "No" << endl;
      return 0;
    }
    queue<long long> is;
    auto ranges = {idx.equal_range(LS[i]), idx.equal_range(RS[i])};
    for (auto range : ranges) {
      for (auto it = range.first; it != range.second; ++it) {
        if (used.count(it->second)) continue;
        is.push(it->second);
      }
    }
    while (is.size()) {
      auto i0 = is.front();
      is.pop();
      if (used.count(i0)) continue;
      used.insert(i0);
      if (!check(LS[i0], RS[i0], DS[i0], dic)) {
        cout << "No" << endl;
        return 0;
      }
      auto ranges0 = {idx.equal_range(LS[i0]), idx.equal_range(RS[i0])};
      for (auto range0 : ranges0) {
        for (auto it = range0.first; it != range0.second; ++it) {
          if (used.count(it->second)) continue;
          is.push(it->second);
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
