#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T1, class T2>
ostream& operator<<(ostream& s, pair<T1, T2> P) {
  return s << '<' << P.first << ", " << P.second << '>';
}
template <class T>
ostream& operator<<(ostream& s, vector<T> P) {
  for (int i = 0; i < P.size(); ++i) {
    if (i > 0) {
      s << " ";
    }
    s << P[i];
  }
  return s;
}
template <class T>
ostream& operator<<(ostream& s, vector<vector<T> > P) {
  for (int i = 0; i < P.size(); ++i) {
    s << endl << P[i];
  }
  return s << endl;
}
template <class T>
ostream& operator<<(ostream& s, set<T> P) {
  for (__typeof__((P).begin()) it = (P).begin(); it != (P).end(); ++it) {
    s << "<" << *it << "> ";
  }
  return s << endl;
}
template <class T1, class T2>
ostream& operator<<(ostream& s, map<T1, T2> P) {
  for (__typeof__((P).begin()) it = (P).begin(); it != (P).end(); ++it) {
    s << "<" << it->first << "->" << it->second << "> ";
  }
  return s << endl;
}
const int MAX = 410000;
int N, M;
int L[MAX], R[MAX], D[MAX];
long long x[MAX];
bool alr[MAX];
string solve() {
  memset(alr, 0, sizeof(alr));
  for (int i = 0; i < M; ++i) {
    int l = L[i] - 1, r = R[i] - 1, d = D[i];
    if (alr[l] && alr[r]) {
      if (x[r] - x[l] != d) {
        return "No";
      }
    } else if (alr[l] && !alr[r]) {
      x[r] = x[l] + d;
    } else if (!alr[l] && alr[r]) {
      x[l] = x[r] - d;
    } else if (!alr[l] && !alr[r]) {
      x[l] = 0;
      x[r] = d;
    }
    alr[l] = true;
    alr[r] = true;
  }
  return "Yes";
}
int main() {
  while (cin >> N >> M) {
    for (int i = 0; i < M; ++i) cin >> L[i] >> R[i] >> D[i];
    cout << solve() << endl;
  }
}
