#include <bits/stdc++.h>

using namespace std;

const int MAXN = 100000;

vector<pair<int, int>> edges[MAXN];
int dist[MAXN];
bool bio[MAXN];

bool dfs(int i)
{
	for (const auto& edge: edges[i])
	{
		if (!bio[edge.first])
		{
			dist[edge.first] = dist[i] + edge.second;
			bio[edge.first] = true;
			if (dfs(edge.first))
				return true;
		}
		else if (dist[edge.first] != dist[i] + edge.second)
			return true;
	}
	return false;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, m, i;
	int l, r, d;
	
	cin>>n>>m;
	
	while (m--)
	{
		cin>>l>>r>>d;
		--l, --r;
		
		edges[l].push_back({r, d});
		edges[r].push_back({l, -d});
	}
	
	for (i = 0; i < n; ++i) if (!bio[i])
	{
		dist[i] = 0;
		bio[i] = true;
		if (dfs(i))
		{
			cout<<"No\n";
			return 0;
		}
	}
	
	cout<<"Yes\n";
}
