#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100005;
int dp[MAX_N];
bool ok = 1;
int n, m;
vector<pair<int, int>> adj[MAX_N];
vector<int> adj_inv[MAX_N];
vector<int> top_order;
void topologicalSort() {
  vector<int> degree(n, 0);
  for (int i = 0; i < n; i++)
    for (auto j : adj[i]) degree[j.first]++;
  queue<int> q;
  for (int i = 0; i < n; i++)
    if (degree[i] == 0) q.push(i);
  int cnt = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    top_order.push_back(u);
    for (auto i : adj[u])
      if (--degree[i.first] == 0) q.push(i.first);
    cnt++;
  }
  if (cnt != n) ok = 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  if (m < 2) {
    cout << "Yes" << endl;
    return 0;
  }
  map<pair<int, int>, int> dt;
  while (m--) {
    int l, r, d;
    cin >> l >> r >> d;
    l--, r--;
    dt[{l, r}] = d;
    adj[l].push_back({r, d});
    adj_inv[r].push_back(l);
  }
  topologicalSort();
  dp[0] = 0;
  for (int i = 1; i < (int)top_order.size() && ok; i++) {
    set<int> poss;
    for (auto j : adj_inv[top_order[i]])
      poss.insert(dp[j] + dt[{j, top_order[i]}]);
    if (poss.size() != 1) ok = 0;
    dp[top_order[i]] = *poss.begin();
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}
