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

struct ques {
	int l,r,d;
}q[200100];
int n,m;
int fa[100100],dep[100100];
bool flag=1;

int find(int x)
{
	if (x==fa[x]) return x; else
	{
		int k=fa[x];
		fa[x]=find(fa[x]);
		dep[x]+=dep[k];
		return fa[x];
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) fa[i]=i;
	for (int i=1;i<=m;i++)
		scanf("%d%d%d",&q[i].l,&q[i].r,&q[i].d);

	for (int i=1;i<=m;i++)
	{
		int x=q[i].l,y=q[i].r,z=q[i].d;
		int fx=find(x),fy=find(y);
		if (fx!=fy) {
			fa[fx]=fy;
			dep[fx]=z-dep[x]+dep[y];
		} else
		if (dep[x]-dep[y]!=z) {
			puts("No");
			flag=0;
			break;
		}
	}
	
	if (flag) puts("Yes");
	return 0;
}