
#include <bits/stdc++.h>

using namespace std;

struct edge {
	int from;
	int to;
	int w;
};


int const N = 1234567;

vector<edge> edges[N];
int d[N];
int was[N];

void dfs(int v, int val) {
	d[v] = val;
	was[v] = true;
	for (auto &e : edges[v]) {
		if (!was[e.to]) {
			dfs(e.to, val + e.w);
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int v, u, d;
		cin >> v >> u >> d;
		--v;
		--u;
		edges[v].push_back({v, u, d});
		edges[u].push_back({u, v, -d});
	}
	for (int i = 0; i < n; i++) was[i] = false;
	for (int i = 0; i < n; i++) {
		if (!was[i]) {
			dfs(i, 0);
		}
	}
	for (int i = 0; i < n; i++) {
		for (auto &e : edges[i]) {
			if (d[e.from] + e.w != d[e.to]) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes\n";
}
