#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int>>> G;
vector<bool> visited;
vector<int> dist;
void dfs(int u) {
  visited[u] = true;
  for (pair<int, int> p : G[u]) {
    int v = p.first;
    if (visited[v]) continue;
    dist[v] = dist[u] + p.second;
    visited[v] = true;
    dfs(v);
  }
}
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> L(M), R(M), D(M);
  G.resize(N);
  for (int i = 0; i < M; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    L[i] = l, R[i] = r, D[i] = d;
    G[l].push_back(pair<int, int>(r, d));
    G[r].push_back(pair<int, int>(l, -d));
  }
  visited.resize(N, false);
  dist.resize(N, 0);
  for (int i = 0; i < N; i++) {
    if (!visited[i]) dfs(i);
  }
  for (int i = 0; i < N; i++) {
    if (D[i] != dist[R[i]] - dist[L[i]]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
