#include <bits/stdc++.h>
using namespace std;
const int inf = (int)2e9, mod = (int)1e9 + 7;
const long long linf = (long long)2e18;
const int maxn = (int)1e5 + 666, maxn2 = (int)1e6 + 666;
set<int> hv, aa[maxn], bb[maxn];
set<pair<int, int> > g[maxn];
map<pair<int, int>, int> p;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, t;
  cin >> n >> t;
  for (int i = 1; i <= t; ++i) {
    int x, y, d;
    cin >> x >> y >> d;
    if (x > y) swap(x, y);
    hv.insert(d);
    g[d].insert(make_pair(x, y));
    aa[x].insert(y);
    bb[y].insert(x);
    p[make_pair(x, y)] = d;
  }
  for (auto it : hv) {
    for (auto x : g[it]) {
      int l = x.first;
      int r = x.second;
      if ((int)aa[l].size() < (int)bb[r].size()) {
        for (auto f : aa[l]) {
          if (bb[r].count(f)) {
            if (p[make_pair(l, f)] + p[make_pair(f, r)] != it) {
              cout << "No";
              exit(0);
            }
          }
        }
      } else {
        for (auto f : bb[r]) {
          if (aa[l].count(f)) {
            if (p[make_pair(l, f)] + p[make_pair(f, r)] != it) {
              cout << "No";
              exit(0);
            }
          }
        }
      }
    }
  }
  cout << "Yes";
  return 0;
}
