#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<vector<pair<int,int>>> A;
vector<bool> visited;
vector<int> pos;
bool g(int p, int q) {
	if (visited[p]) {
		return pos[p] == q;
	} else {
		visited[p] = true;
		pos[p] = q;
		for (auto x : A[p]) {
			if (!g(x.first, q + x.second)) return false;
		}
		return true;
	}
}
bool f() {
	visited.resize(N);
	pos.resize(N);
	for (int i = 0; i < N; ++ i) if (!visited[i]) {
		if (!g(i, 0)) return false;
	}
	return true;
}
int main() {
	cin >> N >> M;
	A.resize(N);
	for (int i = 0; i < M; ++ i) {
		int Li, Ri, Di;
		cin >> Li >> Ri >> Di;
		-- Li; -- Ri;
		A[Li].push_back({Ri, Di});
		A[Ri].push_back({Li, -Di});
	}

	cout << (f() ? "Yes" : "No") << endl;
}
