#include<cstdio>
#include<algorithm>
using namespace std;
const int inf=100005;
int i,j,k,l,n,m,fx,fy;
int tmp[4],fa[inf],dis[inf];
bool f;
int find(int x)
{
	if (fa[x]!=x)
	{
		int org=fa[x];
		fa[x]=find(fa[x]);
		dis[x]+=dis[org];
		return fa[x];
	} 
	else return x;
}
void unite(int x,int y,int z)
{
	fx=find(x);
	fy=find(y);
	if (fx==fy)
	{
		if (dis[y]-dis[x]!=z)
			f=0;
	}
	else
	{
		dis[fy]=z+dis[x]-dis[y];
		fa[fy]=fx;
	}
}
int main()
{
	f=1;
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++)
		fa[i]=i;
	for (i=1;i<=m;i++)
	{
		scanf("%d%d%d",&tmp[1],&tmp[2],&tmp[3]);
		unite(tmp[1],tmp[2],tmp[3]);
		if (!f)
			break;
	}
	if (f)
		printf("Yes");
	else printf("No");
	return 0;
}