#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = 1e9 + 7;
const ll INF = 10000000000;
const int MAX_N = 100000;
int main() {
  cin.sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  if (M == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  map<int, ll> mp;
  map<pair<int, int>, int> mp2;
  vector<pair<int, int>> P(M);
  vector<ll> R(M), L(M), D(M);
  for (int i = 0; i < (int)(M); i++) {
    int d;
    cin >> P[i].first >> P[i].second >> d;
    mp2[P[i]] = d;
  }
  sort(P.begin(), P.end());
  ll sum = 0, start = 10000000000;
  ll r = 0, l = INF;
  for (int i = 0; i < (int)(M); i++) {
    int R = P[i].first, L = P[i].second, D = mp2[P[i]];
    if (mp[R] == 0 && mp[L] == 0) {
      mp[R] = start;
      mp[L] = start - D;
    } else if (mp[R] == 0) {
      mp[R] = mp[L] + D;
    } else if (mp[L] == 0) {
      mp[L] = mp[R] - D;
    } else {
      if (mp[R] - mp[L] != D) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  for (int i = 0; i < (int)(M); i++) {
    int R = P[i].first, L = P[i].second, D = mp2[P[i]];
    if (mp[R] == 0 && mp[L] == 0) {
      mp[R] = start;
      mp[L] = start - D;
    } else if (mp[R] == 0) {
      mp[R] = mp[L] + D;
    } else if (mp[L] == 0) {
      mp[L] = mp[R] - D;
    } else {
      if (mp[R] - mp[L] != D) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
