 #include<iostream>
#include<cstdio>
#include<vector>
using namespace std;

int p[5],v[100005],o[100005],f=1;
vector<int>b[100005];

void dfs(int a,int d){
	int i;
	//cout<<a<<' '<<d<<endl;
	if(o[a]!=0){
		if(v[a]!=d)f=0;
		return;
	}
	
	v[a]=d;
	o[a]=1;
	
	for(i=0;i<b[a].size();i+=2){
		dfs(b[a][i],d+b[a][i+1]);
	}
	
	return;
}

int main(){
	int n,m,i;
	cin>>n>>m;
	
	for(i=1;i<=m;i++){
		cin>>p[1]>>p[2]>>p[3];
		b[p[1]].push_back(p[2]);
		b[p[1]].push_back(p[3]);
		b[p[2]].push_back(p[1]);
		b[p[2]].push_back(0-p[3]);
	}
	
	for(i=1;i<=n;i++){
		if(o[i]==0)dfs(i,0);
	}
	
	if(f==1)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	
	return 0;
}