#include <iostream>
#include <vector>
#include <queue>

#define int long long int

bool visited[100010] = { 0 };
int dist[100010] = { 0 };
bool flag = true;
std::vector< std::vector< int > > check(100010);
std::vector< std::vector< std::pair<int, int> > > g(100010);

void dfss(int index, int count)
{
	dist[index] = count;
	
	for (int i = 0; i < g[index].size(); ++i)
	{
		int next = g[index][i].first;
		int distance = g[index][i].second;
		
		if (dist[next] == -1)
		{
			dfss(next, count + distance);
		}
		else if (dist[next] != count + distance)
		{
			flag = false;
			return;
		}
	}
}

main()
{	
	int n, m;
	std::cin >> n >> m;
	
	for (int i = 0; i < m; ++i)
	{
		int l, r, d;
		std::cin >> l >> r >> d;
		
		--l;
		--r;
		g[l].push_back(std::make_pair(r, d));
		g[r].push_back(std::make_pair(l, -d));
		check[l].push_back(r);
	}
	
	for (int i = 0; i < n; ++i)
		dist[i] = -1;
	
	for (int i = 0; i < n; ++i)
	{
		if (dist[i] == -1)
		{
			dfss(i, 0);
		}
	}
	
	if (flag)
		std::cout << "Yes";
	else
		std::cout << "No";
	
	
}