#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int Max = 200007;
vector<pair<int, int>> G[Max];
int l[Max], r[Max], d[Max], dp[Max];
bool isOK[Max];
int n, m;
string solve() {
  for (int i = 0; i < (n); ++i) dp[i] = Max;
  for (int i = 0; i < (n); ++i) {
    if (isOK[i]) continue;
    dp[i] = 0;
    priority_queue<pair<int, int>, vector<pair<int, int>>,
                   greater<pair<int, int>>>
        que;
    que.push(pair<int, int>(0, i));
    while (!que.empty()) {
      pair<int, int> p = que.top();
      que.pop();
      for (auto e : G[p.second]) {
        if (chmin(dp[e.first], dp[p.second] + e.second)) {
          que.push(pair<int, int>(dp[e.second], e.first));
        }
      }
    }
  }
  for (int i = 0; i < (m); ++i)
    if (dp[r[i]] - dp[l[i]] != d[i]) return "No";
  return "Yes";
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < (Max); ++i) G[i].clear();
  memset(isOK, 0, sizeof(isOK));
  for (int i = 0; i < (m); ++i) {
    cin >> l[i] >> r[i] >> d[i];
    --l[i];
    --r[i];
    G[l[i]].push_back(pair<int, int>(r[i], d[i]));
    isOK[r[i]] = true;
  }
  cout << solve() << endl;
  return 0;
}
