#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> ma;
map<pair<long long, long long>, long long> ma_flag;
map<pair<long long, long long>, long long> ma_index;
void f(long long index) {
  long long l = v[index].second.first;
  long long r = v[index].second.second;
  long long d = v[index].first;
  if (ma_flag[make_pair(l, r)] == 1) return;
  ma_flag[make_pair(l, r)] = 1;
  for (long long i = (index + 1); i < (v.size()); ++i) {
    long long l1 = v[i].second.first;
    long long r1 = v[i].second.second;
    long long d1 = v[i].first;
    if (ma_flag[make_pair(l1, r1)] == 1) continue;
    if (l == l1 && ma[make_pair(r1, r)] != 0) {
      if (d != d1 + ma[make_pair(r1, r)] - 1) {
        flag = 0;
      }
      f(ma_index[make_pair(r1, r)]);
    } else if (r == r1 && ma[make_pair(l, l1)] != 0) {
      if (d != d1 + ma[make_pair(l, l1)] - 1) {
        flag = 0;
      }
      f(ma_index[make_pair(l, l1)]);
    } else {
      f(ma_index[make_pair(l1, r1)]);
    }
  }
}
int main() {
  flag = 1;
  long long n, m;
  cin >> n >> m;
  if (m == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  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)));
    ma[make_pair(a, b)] = c + 1;
  }
  sort((v).begin(), (v).end());
  reverse((v).begin(), (v).end());
  for (long long i = (0); i < (m); ++i) {
    long long l = v[i].second.first;
    long long r = v[i].second.second;
    ma_index[make_pair(l, r)] = i;
  }
  f(0);
  if (flag == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
