#include<bits/stdc++.h>
using namespace std;

const int N=100009;
const int M=200009;

int n,m,l,r,d;
int x[N],fa[N];
int dis[N];

inline int findfa(int x)
{
	if(fa[x]==x)return x;
	int f=findfa(fa[x]);
	dis[x]=dis[x]+dis[fa[x]];
	fa[x]=f;
	return f;
}

int main()
{
	if(fopen("vj.in","r"))
	{
		freopen("vj.in","r",stdin);
		freopen("vj.out","w",stdout);
	}

	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		fa[i]=i,dis[i]=0;

	for(int i=1;i<=m;i++)
	{
		scanf("%d%d%d",&l,&r,&d);
		if(findfa(l)==findfa(r))
		{
			if(dis[l]+d!=dis[r])
			{
				puts("No");
				return 0;
			}
		}
		else	
		{
			int x=findfa(l),y=findfa(r);
			fa[y]=x;dis[y]=dis[l]+d-dis[r];
		}
	}

	puts("Yes");
	return 0;
}
