#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int, int>pii;
vector<pii>pat[100000];
bool flag[100000];
int d[100000];
void dfs(int node, int t)
{
	if (flag[node])
	{
		if (d[node] != t)
		{
			printf("No\n");
			exit(0);
		}
		return;
	}
	flag[node] = true;
	d[node] = t;
	for (int i = 0; i < pat[node].size(); i++)dfs(pat[node][i].first, t + pat[node][i].second);
}
int main()
{
	int num, way;
	scanf("%d%d", &num, &way);
	for (int i = 0; i < way; i++)
	{
		int za, zb, zc;
		scanf("%d%d%d", &za, &zb, &zc);
		za--, zb--;
		pat[za].push_back(make_pair(zb, zc));
		pat[zb].push_back(make_pair(za, -zc));
	}
	for (int i = 0; i < num; i++)
	{
		if (!flag[i])dfs(i, 0);
	}
	printf("Yes\n");
}