#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;
template <class T>
void vin(vector<T>& v, int n) {
  v.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
}
int N, M;
struct E {
  ll l, r, d;
};
vector<E> s;
bool used[101010];
ll dist[101010];
int main() {
  cin >> N >> M;
  bool ok = true;
  for (int(i) = (0); (i) < (int)(M); ++(i)) {
    int l, r, d;
    cin >> l >> r >> d;
    if (l > r) {
      swap(l, r);
      d = -d;
    }
    s.push_back({l, r, d});
  }
  sort(s.begin(), s.end(), [](const E& a, const E& b) {
    if (a.l == b.l) {
      return a.r < b.r;
    } else {
      return a.l < b.l;
    }
  });
  ll mi = 1e10, ma = -1;
  for (int(i) = (0); (i) < (int)(M); ++(i)) {
    E e = s[i];
    ll l = e.l, r = e.r, d = e.d;
    if (!used[l] and !used[r]) {
      dist[l] = 0;
      dist[r] = d;
      used[l] = true;
      used[r] = true;
    } else if (used[l] and !used[r]) {
      dist[r] = dist[l] + d;
      used[r] = true;
    } else if (used[r] and !used[l]) {
      dist[l] = dist[r] - d;
      used[l] = true;
    } else {
      if (dist[r] - dist[l] != d) {
        ok = false;
        break;
      }
    }
    mi = min(mi, dist[l]);
    ma = max(ma, dist[r]);
  }
  cout << (ok ? "Yes" : "No") << endl;
}
