#include <bits/stdc++.h>

using namespace std;

vector<vector<pair<int, int>>> graph;
vector<bool> vis;
vector<int> value;

bool dfs(int u, int val) {
	vis[u] = true;
	value[u] = val;
	for (auto &ed: graph[u]) {
		int v, w;
		tie(v, w) = ed;
		if (vis[v]) {
			if (value[v] != value[u] + w) {
				return false;
			}
		} else {
			if (!dfs(v, value[u] + w)) {
				return false;
			}
		}
	}
	return true;
}

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	graph.assign(n, {});
	vis.resize(n);
	value.resize(n);
	for (int i = 0; i < m; i++) {
		int l, r, d;
		scanf("%d %d %d", &l, &r, &d);
		l--, r--;
		graph[l].push_back({r, d});
		graph[r].push_back({l, -d});
	}
	bool ans = true;
	for (int i = 0; i < n; i++) {
		if (!vis[i] and !dfs(i, 0)) {
			ans = false;
		}
	}
	printf("%s\n", ans ? "Yes" : "No");
	return 0;
}