#include <bits/stdc++.h>
using namespace std;
const long long N = 100010;
const long long INF = 1LL << 55;
const long long mod = (1e9) + 7;
const long double EPS = 1e-8;
const long double PI = 6.0 * asin(0.5);
ostream& operator<<(ostream& o, pair<long long, long long> p) {
  return o << "(" << p.first << "," << p.second << ")";
}
istream& operator>>(istream& i, pair<long long, long long>& p) {
  return i >> p.first >> p.second;
}
template <class T>
istream& operator>>(istream& i, vector<T>& a) {
  for (auto& t : a) cin >> t;
  return i;
}
template <class T>
T Max(T& a, T b) {
  return a = max(a, b);
}
template <class T>
T Min(T& a, T b) {
  return a = min(a, b);
}
template <class T>
void prArr(T a, string s = " ") {
  long long i = 0;
  for (auto t : a) cout << (i++ ? s : "") << t;
  cout << endl;
}
map<long long, long long> M[N];
signed main() {
  long long n, m;
  cin >> n >> m;
  vector<pair<pair<long long, long long>, long long> > A(m);
  for (long long i = 0; i < m; i++) cin >> A[i].first >> A[i].second;
  for (long long i = 0; i < m; i++) {
    auto pp = A[i];
    long long L = pp.first.first;
    long long R = pp.first.second;
    long long D = pp.second;
    A.push_back(pair<pair<long long, long long>, long long>(
        pair<long long, long long>(R, L), -D));
  }
  sort(A.begin(), A.end());
  long long ans = 1;
  for (auto pp : A) {
    long long L = pp.first.first;
    long long R = pp.first.second;
    long long D = pp.second;
    if (M[L].count(R)) ans &= M[L][R] == D;
    if (M[R].count(L)) ans &= M[R][L] == -D;
    M[L][R] = D;
    M[R][L] = -D;
  }
  map<long long, long long> X;
  long long update = 1;
  while (update && ans) {
    update = 0;
    for (auto pp : A) {
      long long L = pp.first.first;
      long long R = pp.first.second;
      long long D = pp.second;
      if (X.count(L) && X.count(R)) {
        ans &= X[L] + D == X[R];
        continue;
      } else if (!X.count(L) && !X.count(R))
        X[L] = 0, X[R] = D;
      else if (!X.count(L))
        X[L] = X[R] - D;
      else if (!X.count(R))
        X[R] = X[L] + D;
      update = 1;
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}
