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

#define int long long

int N, M;
//          id , distance
vector<pair<int, int> >vec[100005];
int pos[100005];
set<int> ok;
 
bool dfs(int pos){
	if(ok.count(pos) != 0)
		return true;
	ok.insert(pos);
	for(int i = 0; i < vec[pos].size(); i++){
		int nextpos = vec[pos][i].first;
		int diff = vec[pos][i].second;
		if(pos[nextpos] != INT_MAX && pos[nextpos] != pos[pos] + diff){
			return false;
		}
		pos[nextpos] = pos[pos] + diff;
		if(dfs(nextpos) == false){
			return false;
		}
	}
	ok.insert(pos);
	return true;
}
 
int main(){
	cin >> N >> M;
	for(int i = 0; i < M; i++){
		int L, R, D;
		cin >> L >> R >> D;
		L--;R--;
		vec[L].push_back(make_pair(R, D));
		vec[R].push_back(make_pair(L, -sD));
	}
 
	for(int i = 0; i < N; i++)
		pos[i] = INT_MAX;
 
 
	for(int i = 0; i < N; i++){
		if(ok.count(i) != 0)
			continue;
		pos[i] = 0;
		if(dfs(i) == false){
			puts("No");
			return 0;
		}
 
	}
 
	puts("Yes");
	return 0;
}

