#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll, ll>;
const ll MOD = 1000000007;
const ll MOD9 = 998244353;
const int inf = 1e9;
const ll INF = 4e18;
const ll dy[4] = {1, 0, -1, 0};
const ll dx[4] = {0, -1, 0, 1};
int main() {
  int N, M;
  cin >> N >> M;
  ll L[M], R[M], D[M];
  for (ll i = 0; i < M; i++) cin >> L[i] >> R[i] >> D[i];
  map<ll, ll> info;
  bool check = 0;
  for (ll i = 0; i < M; i++) {
    if (info.count(L[i])) {
      if (info.count(R[i]) == 0)
        info.emplace(R[i], info[L[i]] + D[i]);
      else if (info[R[i]] != info[L[i]] + D[i])
        check = 1;
    } else if (info.count(R[i])) {
      if (info.count(L[i]) == 0)
        info.emplace(L[i], info[R[i]] - D[i]);
      else if (info[L[i]] != info[R[i]] - D[i])
        check = 1;
    } else {
      info.emplace(L[i], -INF + inf * 2 * i);
      info.emplace(R[i], info[L[i]] + D[i]);
    }
  }
  if (check)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
  return 0;
}
