#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000, unknown = 1e9 + 100;

vector<pair<int,int>> g[MAXN];
int cur[MAXN];

bool dfs(int v) {
  bool ok = 1;
  for (auto P : g[v]) {
    int u = P.first, d = P.second;
    if (cur[u] == unknown) cur[u] = cur[v] + d, ok &= dfs(u);
    else {
      if (cur[u] != cur[v] + d) ok = 0;
    }
  }
  return ok;
}
int main() {
  int N, M, u, v, d; scanf("%d%d", &N, &M);
  for (int i = 0; i < M; ++i) scanf("%d%d%d", &u, &v, &d), --u, --v, g[u].push_back({v, d}), g[v].push_back({u, -d});
  fill(cur, cur + N, unknown);
  bool ok = 1;
  for (int i = 0; i < N; ++i) 
    if (cur[i] == unknown) 
      cur[i] = 0, ok &= dfs(i);
  puts(ok? "Yes": "No");
}

