#include <bits/stdc++.h>
using namespace std;
long long keta(long long x) {
  for (long long i = 0; i < 30; i++) {
    if (x < 10) {
      return i + 1;
    }
    x = x / 10;
  }
}
long long lcm(long long x, long long y) {
  long long aa = x, bb = y;
  for (long long i = 0; i < 1000; i++) {
    aa = aa % bb;
    if (aa == 0) {
      return x / bb * y;
    }
    bb = bb % aa;
    if (bb == 0) {
      return x / aa * y;
    }
  }
}
pair<pair<long long, long long>, long long> p[214514];
long long koho[214514];
bool kimeta[214514];
signed main() {
  long long n;
  cin >> n;
  long long m;
  cin >> m;
  for (long long i = 0; i < m; i++) {
    cin >> p[i].first.first >> p[i].first.second >> p[i].second;
    p[i].first.first -= 1;
    p[i].first.second -= 1;
    if (p[i].first.first > p[i].first.second)
      swap(p[i].first.first, p[i].first.second);
    p[i].second = -p[i].second;
  }
  sort(p, p + m);
  for (long long i = 0; i < n; i++) kimeta[i] = false;
  for (long long i = 0; i < m; i++) {
    if (kimeta[p[i].first.first] == false) {
      koho[p[i].first.first] = 0;
      kimeta[p[i].first.first] = true;
      koho[p[i].first.second] = koho[p[i].first.first] + p[i].second;
      kimeta[p[i].first.second] = true;
    } else if (kimeta[p[i].first.second] == false) {
      kimeta[p[i].first.second] = true;
      koho[p[i].first.second] = koho[p[i].first.first] + p[i].second;
    } else {
      if (koho[p[i].first.second] - p[i].second != koho[p[i].first.first]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}
