#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int MAXN = 200000+9;
int fa[MAXN];
int val[MAXN];
int n,m;

int Find(int x){
	if(fa[x]==x)return x;
	int tmp=fa[x];
	fa[x]=Find(fa[x]);
	val[x]=val[tmp]+val[x];
	return fa[x];
}

void Union(int x,int y,int det){
	int xx=Find(x);int yy=Find(y);
	val[yy]=det;
	fa[yy]=xx;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		fa[i]=i;
	}
	for(int i=1;i<=m;i++){
		int a,b,c;
		scanf("%d%d%d",&a,&b,&c);
		int aa=Find(a);
		int bb=Find(b);
		if(aa==bb){
			if(c!=val[b]-val[a]){
				puts("No");
				return 0;
			}
		}
		else
			Union(a,b,c+val[a]-val[b]);
	}
	puts("Yes");
	return 0;
}

