#include<bits/stdc++.h>
using namespace std;
//#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=2e5+10,inf=1e9+10,mod=1e9+7,M2=1e6+10,M3=3e3+10;
int l[M],r[M],q[M],d[M];
vector<int>adj[M],edg[M],adj2[M],edg2[M];
bool mark[M];
int cur[M];
void dfs(int v)
{
	mark[v]=1;
	for(int i=0;i<adj[v].size();i++)
	{
		int u=adj[v][i];
		if(mark[u] && cur[u]!=edg[v][i]+cur[v])
		{
			cout<<"No";
			exit(0);
		}
		if(!mark[u])cur[u]=cur[v]+edg[v][i],dfs(u);
	}
}
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++)scanf("%d%d%d",&l[i],&r[i],&d[i]),adj[l[i]].pb(r[i]),adj[r[i]].pb(l[i]),edg[l[i]].pb(d[i]),edg[r[i]].pb(-d[i]);	
	int tail=0,head=0;
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(!mark[i])dfs(i);
	}
	cout<<"Yes";
}