#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<pair<int,int> >G[1<<17];
int n,m;
long x[1<<17];bool used[1<<17];
bool dfs(int u,int p)
{
	used[u]=1;
	for(int i=0;i<G[u].size();i++)
	{
		if(G[u][i].first==p)continue;
		if(used[G[u][i].first]&&x[G[u][i].first]!=x[u]+G[u][i].second)return false;
		else if(!used[G[u][i].first])
		{
			x[G[u][i].first]=x[u]+G[u][i].second;
			if(!dfs(G[u][i].first,u))return false;
		}
	}
	return true;
}
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int l,r,d;cin>>l>>r>>d;
		G[l].push_back(make_pair(r,d));
		G[r].push_back(make_pair(l,-d));
	}
	for(int i=1;i<=n;i++)
	{
		if(!used[i])x[i]=0;
		if(!dfs(i,0))
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}