#include <bits/stdc++.h>
using namespace std;
template <class TH>
void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << "=" << h << "\n";
}
template <class TH, class... TA>
void _dbg(const char *sdbg, TH h, TA... a) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << "=" << h << ",";
  _dbg(sdbg + 1, a...);
}
const long long N = 5 * 100 * 1000 + 7;
long long test;
long long n, m;
long long dist[N];
vector<pair<long long, long long> > g[N];
bitset<N> czy;
bool bad = 0;
void solve() {
  cin >> n >> m;
  for (long long i = 1; i <= (m); ++i) {
    long long a, b, c;
    cin >> a >> b >> c;
    g[a].emplace_back(b, c);
    g[b].emplace_back(a, -c);
  }
  for (long long i = 1; i <= (n); ++i) {
    for (auto it : g[i]) {
      if (it.first < i) continue;
      if (czy[it.first] == 0) {
        czy[it.first] = 1;
        dist[it.first] = dist[i] + it.second;
      } else {
        if (dist[it.first] != dist[i] + it.second) {
          bad = 1;
        }
      }
    }
  }
  cout << (bad ? "No" : "Yes");
  return;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.precision(10);
  cout << fixed;
  test = 1;
  while (test--) {
    solve();
  }
  return 0;
}
