#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define N 100005
ll n, m, x, y, z, f[N], d[N], r[N], s;
bool ish(ll q)
{
	return q >= 0;
}
void go(ll w)
{
	ll q = w, e = f[q];
	while (e != f[e])
	{
		d[q] += d[e];
		f[q] = f[e];
		e = f[e];
	}
}
void merge()
{
	ll q = f[x], w = f[y], t = d[x] - d[y] + z;
	if (r[q] < r[w])
		swap(q, w), t = -t;
	f[w] = q;
	d[w] = t;
	r[q] += r[w];
}
int main()
{
	scanf("%lld%lld", &n, &m);
	for (int i = 1; i <= n; i++)
		f[i] = i, r[i] = 1;
	for (int i = 0; i < m; i++)
	{
		scanf("%lld%lld%lld", &x, &y, &z);
		go(x); go(y);
		/*for (int i = 1; i <= n; i++)
			cout << i << " " << d[i] << endl;*/
		if (f[x] == f[y])
		{
			if(d[y]-d[x]!=z)
			{
				cout << "No\n";
				return 0;
			}
		}
		else
			merge();
	}

	cout << "Yes\n";
	return 0;
}