#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cctype>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<ctime>
#include<list>
#include<deque>
#include<bitset>
#include<fstream>
#define ld double
#define ull unsigned long long 
#define ll long long 
#define pii pair<int,int >
#define iiii pair<pii,int >
#define mp make_pair 
#define INF 1000000000
#define MOD 1000000007 
#define MAXN 300010
#define int ll
using namespace std;

bool used[MAXN];
ll len[MAXN];
int n,m;

vector<iiii >v;
vector<int >S[MAXN];


void main()
{
	scanf("%I64d%I64d",&n,&m);
	if(!m||m==1)
	{
		printf("Yes\n");
		return;
	}
	
	memset(len,-1ll,sizeof(len));
	int x,y,z;
	scanf("%I64d%I64d%I64d",&x,&y,&z);x--;y--;
	
	queue<int>qu;
	qu.push(x);qu.push(y);
	
	len[x]=0;len[y]=1ll*z;
	m--;
	
	for(int i=0;i<m;i++)
	{
		int x,y,z;
		scanf("%I64d%I64d%I64d",&x,&y,&z);x--;y--;
		v.push_back(mp(mp(x,y),z));
		S[x].push_back(i);
		S[y].push_back(i);
	}
	

	int p=0;
	
	while (p<m)
	{
		while (!qu.empty())
		{
			int u=qu.front();
			qu.pop();
			for(int i=0;i<S[u].size();i++)
			{
				int j=S[u][i];
				used[j]=true;
				
				int x=v[j].first.first,y=v[j].first.second,z=v[j].second;
				if(len[x]==-1ll)
				{
					qu.push(x);
					len[x]=1ll*len[y]-z;
				}
				else if(len[y]==-1ll)
				{
					qu.push(y);
					len[y]=1ll*len[x]+z;
				}
				else if(len[y]-len[x]!=(ll)(z))
				{
					printf("No\n");
					return;
				}	
			
			}	
		}

		while (p<m&&used[p])p++;
		
		if(p<m)
		{
			used[p]=true;
			qu.push(v[p].first.first);
			qu.push(v[p].first.second);
			
			len[v[p].first.first]=0ll;
			len[v[p].first.second]=1ll*v[p].second;
			p++;
		}

	}
	
	printf("Yes\n");
	
		
	

	return;	
} 