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

int N,M;

bool d[100001];
int v[100001];
vector<pair<int,int>>e[100001];

void dfs(int i,int x){
	d[i]=true;
	v[i]=x;
	for(auto a:e[i]){
		if(d[a.first]){
			if(v[i]+a.second!=v[a.first]){
				cout<<"No";
				exit(0);
			}
		}else{
			dfs(a.first,v[i]+a.second);
		}
	}
}

int main(){
	cin>>N>>M;
	for(int i=0;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(!d[i]){
			dfs(i,0);
		}
	}
	cout<<"Yes";
}
