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

typedef long long ll;
typedef pair <int, int> pii;

const int MAXN = 2e5 + 5;

int N, M;
vector <pii> E[MAXN];
int l[MAXN], r[MAXN], d[MAXN];
bool bio[MAXN];
ll x[MAXN];

void load() {
	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; i++) {
		scanf("%d%d%d", l + i, r + i, d + i);
		E[l[i]].push_back({r[i], d[i]});
		E[r[i]].push_back({l[i], -d[i]});
	}
}

void dfs(int node, ll curr) {
	bio[node] = true;
	x[node] = curr;
	for (auto it : E[node])
		if (!bio[it.first])
			dfs(it.first, curr + it.second);
}

bool solve() {
	for (int i = 1; i <= N; i++)
		if (!bio[i])	
			dfs(i, 0);
	
	for (int i = 0; i < M; i++)
		if (x[r[i]] - x[l[i]] != d[i])
			return false;
	
	return true;
}

int main() {
	load();
	puts(solve() ? "Yes" : "No");
	return 0;
}