#include<iostream>
using namespace std;
const int maxn = 100005;
int f[maxn], sum[maxn];
int find(int a)
{
	if (f[a] != a)
	{
		int pre = f[a];
		f[a] = find(f[a]);
		sum[a] = sum[a] + sum[pre];
	}
	return f[a];
}
void Union(int u, int v, int rootu, int rootv, int val)
{
	f[rootu] = rootv;
	sum[rootu] = -sum[u] + val + sum[v];
}

int main()
{
	int N, M;
	scanf("%d %d", &N, &M);
	for (int i = 1;i <= N;i++)f[i] = i,sum[i]=0;
	int u, v, rootu, rootv, dist;
	bool flag = true;
	for (int i = 1;i <= M;i++)
	{
		scanf("%d %d %d", &u, &v, &dist);
		rootu = find(u);
		rootv = find(v);
		if (rootu != rootv)
		{
			Union(u, v, rootu, rootv, dist);
		}
		else
		{
			if (sum[u] - sum[v] != dist)
				flag = false;
		}
	}
	if (flag)puts("Yes");
	else puts("No");
	return 0;
}