#include <bits/stdc++.h>
using namespace std;
const int inf = 1001001000;
const long long INF = 1LL << 60;
const int MOD = (int)1e9 + 7;
vector<vector<pair<int, int>>> G(100100, vector<pair<int, int>>());
void dfs(int f, vector<int> &dist) {
  for (auto x : G[f]) {
    if (dist[x.first] == inf) {
      dist[x.first] = dist[f] + x.second;
      dfs(x.first, dist);
    }
  }
}
int main() {
  int N, M, l, r, d;
  cin >> N >> M;
  vector<tuple<int, int, int>> edge(M);
  for (int i = 0; i < M; ++i) {
    cin >> l >> r >> d;
    --r;
    --l;
    edge[i] = make_tuple(l, r, d);
    G[r].push_back(make_pair(l, -d));
    G[l].push_back(make_pair(r, d));
  }
  vector<int> dist(N, inf);
  for (int i = 0; i < N; ++i) {
    if (dist[i] == inf) dfs(i, dist);
  }
  bool ans = true;
  for (int i = 0; i < M; ++i) {
    if (dist[get<1>(edge[i])] - dist[get<0>(edge[i])] != get<2>(edge[i]))
      ans = false;
  }
  cout << ((ans) ? "Yes" : "No") << endl;
  return 0;
}
