#include <bits/stdc++.h>

using namespace std;

vector<vector<pair<int, int>>> g;

vector<bool> used;
vector<int> pt;

void dfs(int u, int nw)
{
	if (used[u])
	{
		if (nw != pt[u])
		{
			cout << "No" << endl;
			exit(0);
		}
		return;
	}
	used[u] = true;
	pt[u] = nw;
	for (auto p : g[u])
		dfs(p.first, pt[u] + p.second);
}

int main()
{
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	g.resize(n);
	pt.resize(n);
	used.resize(n);
	while (m--)
	{
		int a, b, d;
		cin >> a >> b >> d;
		--a, --b;
		g[a].emplace_back(b, d);
		g[b].emplace_back(a, -d);
	}
	for (int i = 0; i < n; ++i)
		if (!used[i])
			dfs(i, 0);
	cout << "Yes" << endl;
}

