#include<cstdio>
const int N=1e5+7;
int flag,fa[N],val[N],n,m,i,j,x,y,z,p,q;
int find(int x){
	if(x==fa[x])return x;
	else{
		int tmp=fa[x];fa[x]=find(fa[x]);
		val[x]+=val[tmp];
		return fa[x];
	}
}
int main(){
	for(scanf("%d%d",&n,&m),i=1;i<=n;++i)fa[i]=i;
	for(;m--;){
		scanf("%d%d%d",&x,&y,&z);
		if(flag)continue;
		p=find(x);q=find(y);
		if(p==q){
			if(val[x]-val[y]!=z)flag=1;
		}else{
			fa[p]=q;
			val[p]=z+val[y]-val[x];
		}
	}
	puts(flag?"No":"Yes");
}