#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int n,m,fa[N],dis[N];
int find(int x){
	if (x==fa[x]) return x;
	int y=fa[x];
	fa[x]=find(fa[x]);
	dis[x]+=dis[y];
	return fa[x];
}
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 x=find(l),y=find(r);
		if (x==y&&dis[l]+d!=dis[r]) return puts("No"),0;
		if (x==y) continue;
		fa[x]=y;
		dis[x]=dis[r]-d-dis[l];
	}
	puts("Yes");
	return 0;
}