#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,m,fa[N],di[N];
inline int ask(int x){
	if (fa[x]==x) return x;
	int t=ask(fa[x]);
	di[x]+=di[fa[x]];
	return fa[x]=t;	
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i) fa[i]=i;
	for (int id=1,x,y,z;id<=m;++id){
		scanf("%d%d%d",&x,&y,&z);
		int u=ask(x),v=ask(y),dx=di[x],dy=di[y];
		if (u!=v){
			fa[u]=v;
			di[u]=dy-dx-z;
		}else{
			if (dx+z!=dy) return puts("No"),0;
		}
	}
	puts("Yes");
	return 0;
}
