#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int N=100005;

int n,m;
int fa[N],dis[N];
int find(int x) 
{
	if (x==fa[x]) return x;
	int t=find(fa[x]);
	dis[x]+=dis[fa[x]];
	return fa[x]=t;
}


int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) fa[i]=i;
	
	int x,y,d,fx,fy;
	bool o=true;
	while (m--) 
	{
		scanf("%d%d%d",&y,&x,&d);
		if (!o) continue;

		fx=find(x),fy=find(y);
		if (fx==fy) 
		{
			if (dis[x]-dis[y]!=d) o=false;
		}
		else 
		{
			fa[fx]=fy;
			dis[fx]=-dis[x]+dis[y]+d;
		}
	}
	if (o) puts("Yes");else puts("No");
	return 0;
}