#include<cstdio>
using namespace std;

const int N = 1e5;
int fa[N+2];
long long fv[N+2];
int n,q;

int find_fa(int u)
{
	int i = u; long long t = 0ll;
	while(u!=fa[u]) {t += fv[u]; u = fa[u];}
	long long k = fv[i];
	fv[i] = t;
	while(i!=u)
	{
		t -= k;
		int j = fa[i];
		fa[i] = u;
		i = j;
		k = fv[i];
		fv[i] = t;
	}
	return u;
}

int main()
{
	scanf("%d%d",&n,&q); bool ans = true;
	for(int i=1; i<=n; i++) {fa[i] = i; fv[i] = 0ll;}
	for(int i=1; i<=q; i++)
	{
		int x,y; long long z; scanf("%d%d%lld",&x,&y,&z);
		int p = find_fa(x),q = find_fa(y);
		if(p!=q)
		{
			fa[q] = p; fv[q] = fv[x]+z-fv[y];
		}
		else
		{
			if(z!=fv[y]-fv[x]) {ans = false; break;}
		}
	}
	if(ans==true) printf("Yes\n");
	else printf("No\n");
	return 0;
}