#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<long long>;
using pii = pair<long long, long long>;
const signed INF_ = 1001001001;
const ll INF = 1001001001001001001LL;
const long long DX[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0},
                DY[9] = {-1, 0, 1, 0, -1, 1, 1, -1, 0};
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (auto i = (begin(v)); i != (end(v)); ++i)
    os << *i << (i == end(v) - 1 ? "" : " ");
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto i = (begin(v)); i != (end(v)); ++i) is >> *i;
  return is;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.first >> p.second;
  return is;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
using heap = priority_queue<T, vector<T>, greater<T>>;
struct {
  template <class T>
  operator T() {
    T x;
    cin >> x;
    return x;
  }
} IN;
struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(15) << fixed;
  }
} before_main_function;
bool solve() {
  long long N, M;
  cin >> N >> M;
  vector<vector<pii>> g(N);
  vector<long long> deg(N, 0);
  for (long long i = 0, ilen = (long long)(M); i < ilen; ++i) {
    long long L, R, D;
    cin >> L >> R >> D;
    L--, R--;
    g[L].push_back({R, D});
    deg[R]++;
  }
  vector<long long> tps;
  stack<long long> st;
  for (long long i = 0, ilen = (long long)(N); i < ilen; ++i)
    if (deg[i] == 0) st.push(i);
  while (!st.empty()) {
    long long v = st.top();
    st.pop();
    tps.push_back(v);
    for (auto &e : g[v]) {
      deg[e.first]--;
      if (deg[e.first] == 0) {
        st.push(e.first);
      }
    }
  }
  if (((long long)tps.size()) < N) {
    return false;
  }
  bool ng = false;
  vector<long long> dist(N, INF);
  function<void(long long)> dfs = [&](long long v) {
    for (auto &e : g[v]) {
      if (dist[e.first] != INF && dist[v] + e.second != dist[e.first]) {
        ng = 1;
        return;
      }
      dist[e.first] = dist[v] + e.second;
      dfs(e.first);
    }
  };
  for (long long i = 0, ilen = (long long)(N); i < ilen; ++i) {
    long long v = tps[i];
    if (dist[v] == INF) {
      ng = false;
      dist[v] = 0;
      dfs(v);
      if (ng) return false;
    }
  }
  return true;
}
signed main() {
  cout << (solve() ? "Yes" : "No") << "\n";
  return 0;
}
