#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
ll n,m,fa[N],a[N];
int find(int x)
{
	if(x==fa[x])
		return x;
	int t=fa[x];
	int ft=find(t);
	a[x]+=a[t];
	return fa[x]=ft;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    	fa[i]=i,a[i]=0;
	ll u,v,d;
    bool ok=true;
    while(m--)
    {
    	cin>>u>>v>>d;
    	ll x=find(u),y=find(v);
    	if(x!=y)
    	{
    		if(x>y)
			{
				fa[x]=y;
				a[x]=a[v]-(a[u]+d);
			}		
			else
			{
				fa[y]=x;
				a[y]=a[u]-(a[v]-d);
			}
		}
		else 
		{
			ll t=a[v]-a[u];
			if(t!=d)
				ok=false;
		}
	}
	for(int i=1;i<=n;i++)
	{
		find(i);
		if(a[i]>1e9)
			ok=false;
	}
	puts(ok?"Yes":"No");
    
	    

    return 0;
}