#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<pair<int, int> > G[N], GG[N];
  for (int i = (int)0; i < (int)M; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    G[l].push_back(make_pair(r, d));
    G[l].push_back(make_pair(r, -d));
    GG[r].push_back(make_pair(l, -d));
  }
  int vis[N], col[N];
  memset(vis, 0, sizeof(vis));
  memset(col, 0, sizeof(col));
  for (int i = (int)0; i < (int)N; i++) {
    if (not vis[i]) {
      col[i] = 0;
      vis[i] = 1;
      queue<int> q;
      q.push(i);
      while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int p = (int)0; p < (int)G[v].size(); p++) {
          if (vis[G[v][p].first]) {
            if (col[v] + G[v][p].second != col[G[v][p].first]) {
              cout << "No" << endl;
              return 0;
            }
          } else {
            col[G[v][p].first] = col[v] + G[v][p].second;
            vis[G[v][p].first] = 1;
            q.push(G[v][p].first);
          }
        }
      }
    }
  }
  cout << "Yes" << endl;
}
