#include <bits/stdc++.h>
using namespace std;
template <typename T>
void MACRO_VAR_Scan(T& t) {
  cin >> t;
}
template <typename First, typename... Rest>
void MACRO_VAR_Scan(First& first, Rest&... rest) {
  cin >> first;
  MACRO_VAR_Scan(rest...);
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ;
  long long n, m;
  MACRO_VAR_Scan(n, m);
  ;
  if (m == 0) {
    cout << ("Yes") << endl;
    ;
    return 0;
    ;
  }
  long long l[m], r[m], d[m];
  for (long long i = 0; i < (m); i++) {
    cin >> l[i] >> r[i] >> d[i];
    l[i]--;
    r[i]--;
  }
  long long D[n];
  for (long long i = 0; i < (n); i++) D[i] = -1;
  long long cnt = m;
  D[l[0]] = 0;
  while (cnt)
    for (long long i = 0; i < (m); i++) {
      if (D[l[i]] == -1) continue;
      if (D[r[i]] == -1) {
        D[r[i]] = D[l[i]] + d[i];
        d[i] = -1;
        cnt--;
      } else if (d[i] != -1) {
        if (D[r[i]] == D[l[i]] + d[i]) {
          cnt--;
          d[i] = -1;
        } else {
          cout << ("No") << endl;
          ;
          return 0;
          ;
        }
      }
    }
  cout << ("Yes") << endl;
  ;
  return 0;
  ;
}
