#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  {
    int n, m;
    cin >> n >> m;
    vector<vector<pair<int, int> > > adj(n);
    vector<int> par(n);
    int l, r, d;
    for (int i = 0; i < m; ++i) {
      cin >> l >> r >> d;
      l--, r--;
      adj[l].push_back({r, d});
      par[r]++;
    }
    bool res = true;
    vector<int> vis(n, -1);
    queue<int> q;
    for (int i = 0; i < n; i++) {
      if (par[i] == 0) {
        vis[i] = 0;
        q.push(i);
      }
    }
    for (int i = 0; i < n; ++i) {
      if (vis[i] < 0) {
        q.push(i);
        while (!q.empty()) {
          int t = q.front();
          q.pop();
          for (int k = 0; k < int(adj[t].size()); ++k) {
            pair<int, int> u = adj[t][k];
            if (vis[u.first] < 0) {
              vis[u.first] = u.second + (vis[t] >= 0 ? vis[t] : 0);
              q.push(u.first);
            } else {
              if (vis[u.first] != u.second + (vis[t] >= 0 ? vis[t] : 0)) {
                res = false;
                while (!q.empty()) q.pop();
                break;
              }
            }
          }
        }
      }
      if (!res) break;
    }
    cout << (res ? "Yes" : "No") << '\n';
  }
}
