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

typedef long long ll;

int n, m;
vector<pair<int, int>> e[100005];

ll x[1000005];
bool vis[1000005];

bool ok = true;

void solve(int v) {
	vis[v] = true;
	for (auto p : e[v]) {
		int y = p.first;
		int d = p.second;

		if (vis[y]) {
			if (x[v] + d != x[y]) {
				ok = false;
			}
		} else {
			x[y] = x[v] + d;
			solve(y);
		}
		
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);

	cin >> n >> m;
	for (int i=1; i<=m; i++) {
		int l, r, d;
		cin >> l >> r >> d;
		e[l].push_back({r, d});
		e[r].push_back({l, -d});
	}

	for (int i=1; i<=n; i++) {
		if (!vis[i]) {
			solve(i);
		}
	}

	cout << (ok ? "Yes" : "No") << '\n';
}