#include<cstdio>
const int maxn=100000;
int n,m,fa[maxn+10],dfa[maxn+10];
int getfa(int x){
/*	int u=x,d=0; 
	for(;fa[u]!=u;u=fa[u]) d+=dfa[u];
	for(int i=x,p;fa[i]!=i;i=p){
		p=fa[i]; fa[i]=u; d-=dfa[i]; dfa[i]+=d;
	}*/
	if(fa[x]==x) return x;
	int f=getfa(fa[x]); dfa[x]+=dfa[fa[x]]; return fa[x]=f;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i) fa[i]=i;
	for(int i=1;i<=m;++i){
		int l,r,d; scanf("%d%d%d",&l,&r,&d);
		int ll=getfa(l),rr=getfa(r);
		if(ll!=rr){
			fa[ll]=rr; dfa[ll]=dfa[r]-dfa[l]-d;
		}else if(dfa[r]-dfa[l]-d){
			printf("No"); return 0;
		}
	}
	printf("Yes");
}