#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);
    int l, r, d;
    for (int i = 0; i < m; ++i) {
      cin >> l >> r >> d;
      l--, r--;
      adj[l].push_back({r, d});
    }
    vector<int> vis(n, -1);
    bool res = true;
    queue<pair<int, int> > q;
    for (int i = 0; i < n; ++i) {
      if (vis[i] < 0) {
        q.push({i, 0});
        while (!q.empty()) {
          pair<int, int> t = q.front();
          q.pop();
          for (int k = 0; k < int(adj[t.first].size()); ++k) {
            pair<int, int> u = adj[t.first][k];
            if (vis[u.first] < 0) {
              vis[u.first] = u.second;
              q.push(u);
            } else {
              if (vis[u.first] != t.second + u.second) {
                res = false;
                while (!q.empty()) q.pop();
                break;
              }
            }
          }
        }
      }
      if (!res) break;
    }
    cout << (res ? "Yes" : "No") << '\n';
  }
}
