#include <bits/stdc++.h>
using namespace std;
long long flag;
vector<pair<long long, pair<long long, long long> > > v;
map<pair<long long, long long>, long long> ma1;
int main() {
  flag = 1;
  long long n, m;
  cin >> n >> m;
  if (m == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  set<long long> second;
  for (long long i = (0); i < (m); ++i) {
    long long a, b, c;
    cin >> a >> b >> c;
    if (a > b) swap(a, b);
    v.push_back(make_pair(c, make_pair(a, b)));
    ma1[make_pair(a, b)] = c + 1;
    second.insert(a);
  }
  vector<long long> v1((second).begin(), (second).end());
  map<long long, long long> ma;
  map<long long, long long> mar;
  for (long long i = (0); i < (v1.size()); ++i) {
    ma[v1[i]] = i;
    mar[i] = ma[v1[i]];
  }
  vector<vector<pair<long long, long long> > > vv(
      v1.size(), vector<pair<long long, long long> >());
  for (long long i = (0); i < (v.size()); ++i) {
    long long l = v[i].second.first;
    long long r = v[i].second.second;
    long long d = v[i].first;
    vv[ma[l]].push_back(make_pair(d, r));
  }
  for (long long i = (0); i < (vv.size()); ++i) {
    sort((vv[i]).begin(), (vv[i]).end());
    reverse((vv[i]).begin(), (vv[i]).end());
  }
  for (long long i = (0); i < (vv.size()); ++i) {
    long long l = mar[i];
    long long r = vv[i][0].second;
    long long d = vv[i][0].first;
    for (long long j = (1); j < (vv[i].size()); ++j) {
      long long r1 = vv[i][j].second;
      long long d1 = vv[i][j].first;
      if (ma1[make_pair(r1, r)] != 0) {
        if (d != d1 + ma1[make_pair(r1, r)] - 1) {
          flag = 0;
        }
      }
    }
  }
  if (flag == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
