#include <bits/stdc++.h>
using namespace std;
int n,m,x,y,z,f[100005],w[100005];
void find(int x){
	if (f[x]==x) return;
	find(f[x]); w[x]+=w[f[x]]; f[x]=f[f[x]];
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i) f[i]=i;
	for (int i=1;i<=m;++i){
		scanf("%d%d%d",&x,&y,&z);
		find(x); find(y);
		if (f[x]==f[y]){
			if (w[x]+z!=w[y]){
				puts("No"); return 0;
			}
		}else{
			w[f[y]]=w[x]+z-w[y];
			f[f[y]]=f[x];
		}
	}
	puts("Yes");
	return 0;
}