#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<vector>
#include<stack>
#include<cmath>
#include<queue>
#include<set>
#include<map>
#define N 101000

using namespace std;

int f[N],dis[N];

int find (int x)
{
	if (f[x] != x)
	{
		int tmp = f[x];
		f[x] = find(f[x]);
		dis[x] += dis[tmp];
	}
	return f[x];
}

bool Union (int a,int b,int c)
{
	int A = find(a);
	int B = find(b);
	if (A == B)
		if (dis[b]-dis[a] != c)
			return false;
		else
			return true;
	if (b == B || dis[a] + c >= dis[b])
	{
		f[B] = A;
		dis[B] = dis[a]+c-dis[b];
	}
	else
	{
		f[A] = B;
		dis[A] = dis[b]+c-dis[a];
	}
	return true;
}

int main()
{
	memset (dis,0,sizeof(dis));
	int n,m,a,b,c;
	
	scanf ("%d%d",&n,&m);
	
	for (int i=1;i<=n;i++)
		f[i] = i;
	bool flag = true;
	for (int i=1;i<=m;i++)
	{
		scanf ("%d%d%d",&a,&b,&c);
		if (flag && !Union (a,b,c))
			flag = false;
		//cout<<f[a]<<" "<<dis[a]<<" "<<f[b]<<" "<<dis[b]<<" "<<flag<<endl;
	}
	if (flag)
		printf ("Yes\n");
	else
		printf ("No\n");
	return 0;
}
