#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> g[100005];
int h[100005] = {};
bool vis[100005] = {};
int n, m;
void dfs(int x, long long y, vector<long long> &dist) {
  vis[x] = true;
  for (auto &p : g[x]) {
    int to = p.first;
    long long d = p.second;
    if (vis[to]) {
      if (dist[to] != y + d) {
        cout << "No" << endl;
        exit(0);
      }
      continue;
    }
    dist[to] = y + d;
    dfs(to, y + d, dist);
  }
  return;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    g[l].emplace_back(r, d);
    h[r]++;
  }
  stack<int> st;
  for (int i = 0; i < n; i++) {
    if (h[i] == 0) st.push(i);
  }
  vector<int> res;
  while (st.size()) {
    int x = st.top();
    st.pop();
    res.push_back(x);
    for (auto &p : g[x]) {
      h[p.first]--;
      if (h[p.first] == 0) st.push(p.first);
    }
  }
  if ((int)res.size() != n) {
    cout << "No" << endl;
    return 0;
  }
  for (int i = 0; i < (int)res.size(); i++) {
    int x = res[i];
    if (vis[x]) continue;
    vector<long long> dist(n);
    dfs(x, 0LL, dist);
  }
  cout << "Yes" << endl;
  return 0;
}
