#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e6 + 1, mod = 1e9 + 7, inf = 2e9;
struct edge_list {
  int u, v, w;
} edge[N];
bool vis[N];
int n, m, pos[N];
vector<int> adj[N];
void dfs(int v) {
  vis[v] = 1;
  for (auto id : adj[v]) {
    int u = edge[id].v, w = edge[id].w;
    if (pos[u] == -1) {
      pos[u] = pos[v] + w;
    } else if (pos[u] != pos[v] + w) {
      cout << "No";
      exit(0);
    }
    if (vis[u]) {
      continue;
    }
    dfs(u);
  }
}
int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1, u, v, w; i <= m; i++) {
    cin >> u >> v >> w;
    edge[i] = {u, v, w};
    adj[u].push_back(i);
  }
  memset(pos, -1, sizeof pos);
  for (int i = 1; i <= n; i++) {
    if (!vis[i] && (int)adj[i].size()) {
      pos[i] = 0;
      dfs(i);
    }
  }
  cout << "Yes";
}
