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

#define int long long int

int dist[100010] = { 0 };
bool flag = true;

void bfs(std::vector< std::vector< std::pair<int, int> > > &g, int index)
{
	std::queue<int> q, qcount;
	q.push(index);
	qcount.push(0);
	
	while (q.empty() == false)
	{
		int top = q.front(), count = qcount.front();
		
		if (count != dist[top] && dist[top] != -1)
		{
			flag = false;
			return;
		}
		
		if (dist[top] == -1)
			dist[top] = count;
		
		q.pop();
		qcount.pop();
		
		for (int i = 0; i < g[top].size(); ++i)
		{
			int next = g[top][i].first;
			int distance = g[top][i].second;
			
			if (dist[next] == -1)
			{
				q.push(next);
				qcount.push(count + distance);
				dist[next] = count + distance;
			}
			else
			{
				if (count + distance != dist[next])
				{
					flag = false;
					return;
				}
			}
		}
	}
}

main()
{	
	int n, m;
	std::cin >> n >> m;
	
	std::vector< std::vector< std::pair<int, int> > > g(n + 1);
	
	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));
	}
	
	for (int i = 0; i < n; ++i)
		dist[i] = -1;
	
	for (int i = 0; i < n; ++i)
	{
		if (dist[i] == -1 && flag && g[i].size() > 0)
		{
			bfs(g, i);
		}
	}
	
	if (flag)
		std::cout << "Yes";
	else
		std::cout << "No";
}