#include<iostream>
#include<cstring>
#include<cstdio>
#define N 100010
using namespace std;
int fa[N],d[N];
inline int findf(int x)
{
	int fx=x,y,sav,s=0;
	while(fx^fa[fx]) s+=d[fx],fx=fa[fx];
	while(x^fx) sav=d[x],d[x]=s,s-=sav,
				y=fa[x],fa[x]=fx,x=y;
	return fx;
}
int main()
{
	int n,m,f=1;scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) fa[i]=i,d[i]=0;
	while(m--)
	{
		int x,y,z;scanf("%d%d%d",&x,&y,&z);
		int fx=findf(x),fy=findf(y);
		if(fx^fy) fa[fx]=fy,d[fx]=z+d[y]-d[x];
		else if(d[x]-d[y]==z) continue;
		else {	f=0;break;	}
	}
	if(f) printf("Yes\n");
	else printf("No\n");
	return 0;
}