#include<bits/stdc++.h>
#define N 200005
using namespace std;
int n,m;
int f[N],d[N];
int find(int x)
{
	if(x==f[x])return x;
	int nf=find(f[x]);
	d[x]+=d[f[x]];
	return f[x]=nf;
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)f[i]=i;
	int t1,t2,t3;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d%d",&t1,&t2,&t3);
		int aa=find(t1),bb=find(t2);
		if(aa!=bb)
		{
			f[aa]=bb;
			d[aa]=d[t2]-d[t1]-t3;
		}
		else
		{
			if(d[t2]-d[t1]!=t3)return puts("No"),0;
		}
	}
	puts("Yes");
	return 0;
}