#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll n, m;
vector<pair<ll, ll>> v[100000];
bool used[100000];
ll koko[100000];
bool dfs(ll now){
	bool ret = 1;
	for(pair<ll, ll> next : v[now]){
		if(used[next.first]){
			if(koko[next.first] != koko[now] + next.second) return false;
		}else{
			used[next.first] = 1;
			koko[next.first] = koko[now] + next.second;
			ret &= dfs(next.first);
		}
	}
	return ret;
}
int main(){
	cin >> n >> m;
	for(ll i = 0; i < m; i++){
		ll l, r, d; cin >> l >> r >> d;
		v[--l].push_back(pair<ll, ll>(--r, d));
		v[r].push_back(pair<ll, ll>(l, -d));
	}
	bool ans = 1;
	for(ll i = 0; i < n; i++){
		if(!used[i]){
			used[i] = 1;
		}
		ans &= dfs(i);
	}
	cout << (ans ? "Yes\n" : "No\n");
	return 0;
}