#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<vector<pair<int, int>>> v(n, vector<pair<int, int>>());
	for (int i = 0; i < m; i++) {
		int l, r, d;
		cin >> l >> r >> d;
		l--;
		r--;
		v[l].push_back(make_pair(r, d));
		v[r].push_back(make_pair(l, -d));
	}
	bool f = true;
	vector<int> x(n, INT_MAX);
	for (int i = 0; i < n && f; i++) {
		if (x[i] == INT_MAX) {
			x[i] = 0;
			queue<int> q;
			q.push(i);
			while (!q.empty() && f) {
				int j = q.front();
				q.pop();
				for (auto p : v[j]) {
					if (x[p.first] == INT_MAX) {
						x[p.first] = x[j] + p.second;
						q.push(p.first);
					} else {
						if (x[p.first] != x[j] + p.second) {
							f = false;
							break;
						}
					}
				}
			}
		}
	}
	cout << (f ? "Yes" : "No") << endl;
	return 0;
}
