#include<iostream>
#define int long long
using namespace std;
int n,p[200000],w[200000],m;
int find(int x)
{
	if(p[x]==x)return x;
	int F=p[x];
	p[x]=find(p[x]);
	w[x]+=w[F];
	return p[x];
}
signed main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)p[i]=i;
	while(m--)
	{
		int l,r,d;
		cin>>l>>r>>d;
		int x=find(l),y=find(r);
		if(x==y&&w[r]-w[l]!=d){cout<<"No"<<endl;return 0;}
		else p[y]=x,w[y]=w[l]+d-w[r];
	}
	cout<<"Yes"<<endl;
	return 0;
}