#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using ld = long double;
int ctoi(const char c) {
  if ('0' <= c && c <= '9') return (c - '0');
  return -1;
}
ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
constexpr ll MOD = 1000000007;
constexpr ll INF = 1000000011;
constexpr ll MOD2 = 998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS = 10e-8;
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 (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto&& x : v) is >> x;
  return is;
}
template <typename T, typename U>
istream& operator>>(istream& is, pair<T, U>& p) {
  is >> p.first;
  is >> p.second;
  return is;
}
template <typename T, typename U>
ostream& operator>>(ostream& os, const pair<T, U>& p) {
  os << p.first << ' ' << p.second;
  return os;
}
template <class T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto i = begin(v); i != end(v); ++i) {
    if (i != begin(v)) os << ' ';
    os << *i;
  }
  return os;
}
vector<vector<pair<ll, ll>>> E(100007);
ll indeg[100007];
ll N, M, Y = 0;
bool B[100007];
void bfs(ll s) {
  ll kyori[100007];
  for (ll i = 0; i < (N + 1); ++i) {
    kyori[i] = -1;
  }
  queue<pair<ll, ll>> Q;
  Q.push(make_pair(s, 0));
  B[s] = true;
  kyori[s] = 0;
  while (!Q.empty()) {
    auto u = Q.front();
    Q.pop();
    for (ll i = 0; i < (E[u.first].size()); ++i) {
      ll v = E[u.first][i].first;
      indeg[v]--;
      if (kyori[v] != -1 && kyori[v] != u.second + E[u.first][i].second) {
        Y = 1;
      } else {
        kyori[v] = u.second + E[u.first][i].second;
      }
      if (indeg[v] == 0 && !B[v]) {
        B[v] = true;
        Q.push(make_pair(v, u.second + E[u.first][i].second));
      }
    }
  }
}
void topological_sort() {
  for (ll i = 0; i < (N + 1); ++i) {
    indeg[i] = 0;
  }
  for (ll i = 0; i < (N + 1); ++i) {
    for (ll j = 0; j < (E[i].size()); ++j) {
      indeg[E[i][j].first]++;
    }
  }
  for (ll i = (1); i < (N + 1); ++i) {
    if (!B[i]) {
      bfs(i);
    }
  }
}
int main() {
  cin >> N >> M;
  for (ll i = 0; i < (N + 1); ++i) {
    B[i] = false;
  }
  for (ll i = 0; i < (M); ++i) {
    ll L, R, X;
    cin >> L >> R >> X;
    E[L].push_back(make_pair(R, X));
  }
  topological_sort();
  if (Y == 1) {
    cout << "No" << '\n';
  } else {
    cout << "Yes" << '\n';
  }
}
