#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
ll test[12345678], res[12345678];
signed main() {
  ll n, m, a, b, c, ans = 0;
  cin >> n >> m;
  vector<ll> v(n + 1);
  for (int h = 0; h < m; h++) {
    cin >> a >> b >> c;
    if (h == 0) {
      v[a] = 1;
      v[b] = v[a] + c;
    } else if (v[a] != 0 && v[b] != 0) {
      if (v[b] - v[a] != c) {
        cout << "No" << endl;
        return 0;
      }
    } else if (v[b] == 0) {
      v[b] = v[a] + c;
    } else {
      v[a] = v[b] - c;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
