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

struct Edge{
	int to;
	ll D;
};

vector<Edge> G[100000];
ll X[100000];
int vis[100000];
bool ok = 1;

void dfs(int v){
	vis[v] = 1;
	for(auto e : G[v]){
		if(vis[e.to]){
			if(X[v] + e.D != X[e.to]) ok = 0;
		}
		else{
			X[e.to] = X[v] + e.D;
			dfs(e.to);
		}
	}
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N, M;
	cin >> N >> M;
	for(int i = 0; i < M; i++){
		int L, R, D;
		cin >> L >> R >> D;
		L--, R--;
		G[L].push_back({ R, D });
		G[R].push_back({ L, -D });
	}

	for(int i = 0; i < N; i++){
		if(vis[i]) continue;
		X[i] = 0;
		dfs(i);
	}

	if(ok){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}
