#include <bits/stdc++.h>
const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;
using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
bool paircomp(const pair<ll, ll> &a, const pair<ll, ll> &b) {
  if (a.first == b.first) return a.second < b.second;
  return a.first < b.first;
}
ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}
struct Edge {
  ll src, dst;
  ll weight;
  Edge(ll src, ll dst, ll weight) : src(src), dst(dst), weight(weight) {}
};
bool operator<(const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight
         : e.src != f.src     ? e.src < f.src
                              : e.dst < f.dst;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, M;
  cin >> N >> M;
  vector<vector<Edge>> G(N);
  for (ll i = 0; i < (M); i++) {
    ll l, r, d;
    cin >> l >> r >> d;
    G[l - 1].push_back(Edge(l - 1, r - 1, d));
  }
  bool ok = true;
  for (ll i = 0; i < (N); i++) {
    queue<pair<ll, ll>> que;
    vl dp(N, llINF);
    que.push(make_pair(i, 0));
    while (!que.empty()) {
      pair<ll, ll> now = que.front();
      que.pop();
      if (dp[now.first] == llINF)
        dp[now.first] = now.second;
      else if (dp[now.first] != now.second) {
        ok = false;
        break;
      }
      for (auto &g : G[now.first]) {
        que.push(make_pair(g.dst, g.weight + now.second));
      }
    }
    if (!ok) break;
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}
