#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<pair<int, int> > adj[100010];
int assigned[100010], val[100010];
bool poss = false;
void possible(int a, int v)
{
	if (assigned[a] && val[a] != v) poss = false;
	if (assigned[a]) return;
	assigned[a] = true;
	val[a] = v;
	for (auto b : adj[a]) possible(b.first, v + b.second);
}
int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++)
	{
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		adj[a].emplace_back(b, c);
		adj[b].emplace_back(a, -c);
	}
	poss = true;
	for (int i = 0; i < n; i++)
	{
		if (!assigned[i]) possible(i, 0);
	}
	if (!poss) printf("No\n");
	else printf("Yes\n");
}
