#include <bits/stdc++.h>
using namespace std;

const int MAXN = 100010;

typedef long long ll;
const int mod = 1e9 + 7;

#define X first
#define Y second

vector<pair<int, int> > E[MAXN];
bool flag = true;
bool vis[MAXN];
int d[MAXN];

void dfs(int x)
{
	for (auto e: E[x])
	{
		int y = e.X, z = e.Y;
		if (!vis[y])
		{
			vis[y] = true;
			d[y] = d[x] + z;
			dfs(y);
		}
		else if (d[y] != d[x] + z) flag = false;
	} 
}

int main()
{
	//freopen("input", "r", stdin);

	int n, m, x, y, z;
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= m; ++i)
	{
		scanf("%d %d %d", &x, &y, &z);
		E[x].push_back(make_pair(y, z));
		E[y].push_back(make_pair(x, -z));
	}
	
	for (int i = 1; i <= n; ++i)
		if (!vis[i]) vis[i] = true, d[i] = 0, dfs(i);
	
	puts(flag? "Yes":"No");

    return 0;
}