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

const int N = 100005;
const int M = 200005;

int n, m;
vector< pair<int,int> > G[N];
bool vis[N];
int dep[N];
int deg[N];

void dfs(int u) {
	vis[u] = 1;
	for (auto e : G[u]) {
		if (!vis[e.second]) {
			dep[e.second] = dep[u] + e.first;
			dfs(e.second);
		} else {
			if (dep[e.second] != dep[u] + e.first) {
				cout << "No\n"; exit(0);
			}
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	while(m--) {
		int l, r, d; cin >> l >> r >> d;
		G[l].push_back(make_pair(d, r));
		G[r].push_back(make_pair(-d, l));
		deg[r]++;
	}

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

	for (int i = 1; i <= n; ++i) if (!vis[i]) {
		cout << "No\n"; return 0;
	}

	cout << "Yes\n";
}