#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];
main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++)cin>>l[i]>>r[i]>>d[i],adj[l[i]].pb(r[i]),adj2[r[i]].pb(l[i]),edg[l[i]].pb(d[i]),edg2[r[i]].pb(d[i]);	
	int tail=0,head=0;
	int cnt=0;
	while(true)
	{
		int head=0,tail=0;
		for(int i=1;i<=n;i++)
		{
			if(!mark[i])
			{
				q[head++]=i;
				mark[i]=1;
				break;
			}
		}
		if(head==0)return cout<<"Yes",0;
		while(head>tail)
		{
			int now=q[tail++];
			for(int j=0;j<adj[now].size();j++)
			{
				int u=adj[now][j];
				if(mark[u] && cur[u]!=cur[now]+edg[now][j])return cout<<"No",0;
				if(mark[u])continue;
				cur[u]=cur[now]+edg[now][j];
				q[head++]=u;
				mark[u]=1;
			}
			for(int j=0;j<adj2[now].size();j++)
			{
				int u=adj2[now][j];
				if(mark[u] && cur[u]!=cur[now]-edg2[now][j])return cout<<"No",0;
				if(mark[u])continue;
				cur[u]=cur[now]-edg2[now][j];
			}
		}
	}
}