#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e15;
const int Nmax = 1000000;
const int Mmax = 2000000;
long long L[Mmax], R[Mmax], D[Mmax], N, M;
long long dfs(int v, vector<vector<pair<int, long long> > > &graph,
              vector<long long> &position) {
  for (int i = 0; i < graph[v].size(); i++) {
    int u = graph[v][i].first;
    long long d = graph[v][i].second;
    if (position[u] == -INF) {
      position[u] = position[v] + d;
      long long diff = dfs(u, graph, position);
      if (diff != 0) {
        position[u] = -INF;
        return diff;
      }
    } else if (position[u] != position[v] + d) {
      return position[v] + d - position[u];
    }
  }
  return 0;
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> L[i] >> R[i] >> D[i];
    L[i]--;
    R[i]--;
  }
  vector<vector<pair<int, long long> > > graph(N);
  for (int i = 0; i < M; i++) {
    graph[L[i]].push_back(make_pair(R[i], D[i]));
  }
  vector<long long> position(N, -INF);
  for (int i = 0; i < N; i++) {
    if (position[i] > -INF) continue;
    position[i] = 0;
    long long diff = dfs(i, graph, position);
    if (diff != 0) {
      position[i] = -diff;
      diff = dfs(i, graph, position);
      if (diff != 0) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
