#include<cstdio>
#include<vector>
#include<algorithm>
#define MAXN 100006
using namespace std;
int fa[MAXN],re[MAXN],n,b,a,d,m;
int root(int x)
{
	if(fa[x]==x) return x;
	int lastfa=fa[x];
	int haha=root(fa[x]);
	re[x]=re[x]+re[lastfa];
	fa[x]=haha;
	return haha;
}
bool work()
{
	for(int i=1;i<=n;i++)
		fa[i]=i;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d%d",&a,&b,&d);
		int roota=root(a);
		int rootb=root(b);
		if(roota==rootb)
		{
			if(re[a]!=re[b]+d) return 0;
		}
		else
		{
			fa[roota]=rootb;
			re[roota]=d+re[b]-re[a];
		}
	}
	return 1;
}
int main()
{
	scanf("%d%d",&n,&m);
	if(work()) printf("Yes");
	else printf("No");
}