#include <bits/stdc++.h>
using namespace std;
template <typename X>
bool exist(vector<X> vec, X item) {
  return find(vec.begin(), vec.end(), item) != vec.end();
}
long long P1[100010];
long long P2[100010];
bool func(pair<pair<long long, long long>, long long> a,
          pair<pair<long long, long long>, long long> b) {
  if (a.first.first == b.first.first)
    return a.first.second <= b.first.second;
  else
    return a.first.first <= b.first.first;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, M;
  cin >> N >> M;
  vector<pair<pair<long long, long long>, long long> > info;
  vector<long long> pel;
  bool flag1 = true, flag2 = true;
  for (long long i = (long long)0; i < (long long)M; i++) {
    long long l, r, d;
    cin >> l >> r >> d;
    if (l > r) {
      swap(l, r);
      d = -d;
    }
    info.push_back(make_pair(make_pair(l, r), d));
  }
  sort(info.begin(), info.end(), func);
  for (long long i = (long long)0; i < (long long)info.size(); i++) {
    long long l, r, d;
    l = info[i].first.first;
    r = info[i].first.second;
    d = info[i].second;
    if (P1[l] == 0) P1[l] = 10000000000;
    long long des = P1[l] + d;
    if (P1[r] == 0)
      P1[r] = des;
    else if (P1[r] == des)
      continue;
    else {
      flag1 = false;
      pel.push_back(l), pel.push_back(r);
    }
  }
  for (long long j = (long long)0; j < (long long)5; j++) {
    for (long long i = (long long)0; i < (long long)info.size(); i++) {
      long long l, r, d;
      l = info[i].first.first;
      r = info[i].first.second;
      d = info[i].second;
      bool e1 = find(pel.begin(), pel.end(), l) != end(pel);
      bool e2 = find(pel.begin(), pel.end(), r) != end(pel);
      if (e1) pel.push_back(l), pel.push_back(r);
      if (e2) pel.push_back(l), pel.push_back(r);
    }
    sort(pel.begin(), pel.end()),
        pel.erase(unique(pel.begin(), pel.end()), pel.end());
  }
  sort(info.rbegin(), info.rend(), func);
  for (long long i = (long long)0; i < (long long)info.size(); i++) {
    long long l, r, d;
    l = info[i].first.first;
    r = info[i].first.second;
    d = info[i].second;
    bool e = find(pel.begin(), pel.end(), l) != end(pel);
    if (!e) continue;
    if (P2[l] == 0) P2[l] = 10000000000;
    long long des = P2[l] + d;
    if (P2[r] == 0)
      P2[r] = des;
    else if (P2[r] == des)
      continue;
    else {
      flag2 = false;
    }
  }
  if (flag1 || flag2)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
