#include<bits/stdc++.h>
using namespace std; 
#define ll long long int
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define INF LLONG_MAX
#define PI acos(-1)
const ll MOD = 1e9 + 7;
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define rep(c,a,b) for(ll c=a;c<b;c++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define min_heap priority_queue<pll,vector<pll>,greater<pll> >
ll dx4[]={-1,1,0,0};
ll dy4[]={0,0,-1,1};
ll dx8[]={-1,-1,-1,0,1,1,1,0};
ll dy8[]={-1,0,1,1,1,0,-1,-1};
bool isvalid(ll x,ll y,ll n,ll m)
{
	return (x>=0 and y>=0 and x<n and y<m);
}
ll isprime[1000];
vector<ll> prime;
void sievetoprime(ll n)
{
	mem(isprime,true);
	for(ll p=2;p*p<=n;p++)
	{
		if(isprime[p]==true)
		{
			for(ll i=p*p;i<=n;i+=p)
				isprime[i]=false;
		}
	}
}
ll lcm(ll a,ll b)
{
	return (a/__gcd(a,b))*b;
}
bool cmp(pair<ll,pll> a,pair<ll,pll> b)
{
	if(a.fir<b.fir)
		return true;
	if(a.fir==b.fir)
	{
		if(a.sec.fir<b.sec.fir)
			return true;
		return false;
	}
	return false;
}
void solve()
{
	ll n,m;
	cin>>n>>m;
	vector<pair<ll,pll> > v;
	ll l,r,d;
	for(ll i=0;i<m;i++)
	{
		cin>>l>>r>>d;
		v.pb(mp(l,mp(r,d)));
	}
	sort(all(v),cmp);
	ll a[n+1]={0};
	ll vis[n+1]={0};
	vis[1]=1;
	for(ll i=0;i<m;i++)
	{
		l=v[i].fir;
		r=v[i].sec.fir;
		d=v[i].sec.sec;
		if(vis[r]==0 and vis[l]==1)
		{
			vis[r]=1;
			a[r]=a[l]+d;
		}
		else if(vis[r]==0 and vis[l]==0)
		{
			a[l]=0;
			a[r]=a[l]+d;
			vis[r]=1;
			vis[l]=1;
		}
		else if(vis[r]==1 and vis[l]==0)
		{
			a[l]=a[r]-d;
			vis[l]=1;
		}
		else if(vis[r] and vis[l])
		{
			if(a[r]-a[l]!=d)
			{
				cout<<"No\n";
				return;
			}
		}
	}
	cout<<"Yes\n";
}	
 
int main()
{
	IOS
	ll t;
	t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}