#include "bits/stdc++.h"
using namespace std;
typedef pair<int, int> P;
int x[100000];
vector<P> G[100000];
bool vis[100000];
bool dfs(int v, int now) {
	vis[v] = 1;
	x[v] = now;
	for (auto e : G[v]) {
		int to = e.first;
		int d = e.second;
		if (!vis[to]) {
			if (!dfs(to, now + d)) return false;
		}
		else if (x[v] + d != x[to]) {
			return false;
		}
	}
	return true;
}
int main() {
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int L, R, D;
		cin >> L >> R >> D;
		L--; R--;
		G[L].push_back(P(R, D));
		G[R].push_back(P(L, -D));
	}
	for (int i = 0; i < N; i++) {
		if (!vis[i]) {
			if (!dfs(i, 0)) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}