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

const int maxn=1e5+10;
int n,m,fa[maxn],pos[maxn];

int findfa(int x){
	if(fa[x]==x)return x;
	int f=findfa(fa[x]);
	pos[x]=pos[x]+pos[fa[x]];
	fa[x]=f;
	return f;
}

int main(){
	cin>>n>>m;
	for(int i=1;i<=n;++i)
		fa[i]=i;
	for(int i=1,l,r,d;i<=m;++i){
		cin>>l>>r>>d;
		if(findfa(l)==findfa(r)){
			if(pos[l]+d!=pos[r]){
				puts("No");
				return 0;
			}
		}
		else{
			int x=findfa(l),y=findfa(r);
			fa[y]=x;
			pos[y]=pos[l]+d-pos[r];
		}
	}
	puts("Yes");
	return 0;
}