#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
long long n,m,i,j,dis[100005],x,y,z;
vector<pair<long long,long long>/**/> e[100005];
void dfs(long long x,long long dist)
{
	if (dis[x])
	{
		if (dis[x]!=dist)
		{
			cout<<"No";
			exit(0);
		}
		return;
	}
	dis[x]=dist;
	int i;
	for (i=0;i<e[x].size();i++)
	{
		dfs(e[x][i].first,dist+e[x][i].second);
	}
}
int main()
{
	cin>>n>>m;
	while (m--)
	{
		cin>>x>>y>>z;
		e[x].push_back(make_pair(y,z));
		e[y].push_back(make_pair(x,-z));
	}
	for (i=1;i<=n;i++)
	{
		if (dis[i]) continue;
		dfs(i,1e15);
	}
	cout<<"Yes";
	return 0;
}