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

using ll = long long;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SIZE(a) ((int)(a).size())

const int N = 100005;

int n, m;
vector<pair<int,int>> g[N];
int was[N];
int dist[N];

void die() {
	cout << "No\n";
	exit(0);
}

void dfs(int v, int d = 0) {
	was[v] = 1;
	dist[v] = d;
	for (auto& item : g[v]) {
		int to = item.first;
		int c = item.second;
		if (!was[to]) {
			dfs(to, d + c);
		} else {
			if (dist[to] != d + c) {
				die();
			}
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	cin >> n >> m;
	REP(i, m) {
		int x, y, c;
		cin >> x >> y >> c;
		--x; --y;
		g[x].emplace_back(y, c);
		g[y].emplace_back(x, -c);
	}
	REP(i, n) if (!was[i]) dfs(i);
	cout << "Yes\n";
	return 0;
}