#include<iostream>
#include<cstdio>
#define maxn 100005
using namespace std;
int dis[maxn],pre[maxn];
int find(int x){
	while(x!=pre[x]){
		int r = pre[x];
		x = r;
	}
	return x;
}
void merge(int x,int y,int d){
	int fx = find(x);
	int fy = find(y);
	if(fx!=fy){
		pre[fy] = pre[fx];
		dis[y]  = dis[x]+d;
	}
}
int main()
{
	int n,m;
	bool ans = true;
	cin>>n>>m;
	for(int i=1;i<=n;i++) pre[i] = i;
	for(int i=0;i<m;i++){
		int x,y,d;
		cin>>x>>y>>d;
		if(pre[x]!=pre[y]) merge(x,y,d);
		else  if(dis[y]!=d) ans = false;
	} 
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
 } 