#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
bool rec(vector<pair<pair<int, int>, ll>> &V) {
  int N = V.size();
  if (N == 0) return true;
  map<int, ll> mp;
  mp[V[0].first.first] = 0, mp[V[0].first.second] = V[0].second;
  for (int i = 1; i < N; i++) {
    auto L = V[i].first.first, R = V[i].first.second;
    auto d = V[i].second;
    if (mp.find(L) != mp.end() && mp.find(R) != mp.end()) {
      if (mp[R] - mp[L] != d) return false;
    } else if (mp.find(L) != mp.end()) {
      mp[R] = mp[L] + d;
    } else if (mp.find(R) != mp.end()) {
      mp[L] = mp[R] - d;
    } else {
      mp[L] = 0;
      mp[R] = d;
    }
  }
  return true;
}
int N, M;
int main() {
  cin >> N >> M;
  vector<pair<pair<int, int>, ll>> V;
  for (int i = 0; i < M; i++) {
    int a, b;
    ll c;
    cin >> a >> b >> c;
    if (a > b) {
      swap(a, b);
      c *= -1;
    }
    pair<int, int> p = make_pair(a, b);
    V.emplace_back(p, c);
  }
  sort(V.begin(), V.end());
  cout << (rec(V) ? "Yes" : "No") << endl;
}
