#include<cstdio>
inline int read()
{
	int x;char c;
	while((c=getchar())<'0'||c>'9');
	for(x=c-'0';(c=getchar())>='0'&&c<='9';)x=x*10+c-'0';
	return x;
}
#define MN 100000
#define MM 200000
struct edge{int nx,t,w;}e[MM*2+5];
int h[MN+5],en,u[MN+5],z[MN+5],O;
inline void ins(int x,int y,int w)
{
	e[++en]=(edge){h[x],y,w};h[x]=en;
	e[++en]=(edge){h[y],x,-w};h[y]=en;
}
void dfs(int x)
{
	u[x]=1;
	for(int i=h[x];i;i=e[i].nx)
		if(!u[e[i].t])z[e[i].t]=z[x]+e[i].w,dfs(e[i].t);
		else O|=z[e[i].t]!=z[x]+e[i].w;
}
int main()
{
	int n,m,x,y,i;
	n=read();m=read();
	while(m--)x=read(),y=read(),ins(x,y,read());
	for(i=1;i<=n;++i)if(!u[i])dfs(i);
	puts(O?"No":"Yes");
}