#include <stdio.h>

#define ARC(i,a,b) for(int i=(a);i<(b);++i)
#define ARCH(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RC(i,n) ARC(i,0,n)
#define RCH(i,n) ARCH(i,n,0)
#define SRC(i,s) for(Int i=0;(s)[i];++i)
#define ATH(a,b) ((a)>(b)?(a):(b))
#define OTH(a,b) ((a)<(b)?(a):(b))
#define ANTH(a,b) {if((a)<(b))(a)=(b);}
#define ONTH(a,b) {if((a)>(b))(a)=(b);}
#define ACH printf
#define ECH scanf
#define AC putchar
#define EC getchar
#define _ AC('\n');

int main() {
	int n, m;
	static int tr[2][110000];
	int ans;
	ECH("%d%d", &n, &m);
	ans = n;
	RC(i, n) tr[1][i] = i;
	RC(i, n) tr[2][i] = 0;
	RC(i, m){
		int l, r, d;
		ECH("%d%d%d", &l, &r, &d);
		while(tr[1][l] != tr[1][tr[1][l]]){
			tr[2][l] += tr[2][tr[1][l]];
			tr[1][l] = tr[1][tr[1][l]];
		}
		while(tr[1][r] != tr[1][tr[1][r]]){
			tr[2][r] += tr[2][tr[1][r]];
			tr[1][r] = tr[1][tr[1][r]];
		}
		if(tr[1][tr[1][l]] == tr[1][tr[1][r]]){
			if(tr[2][r] - tr[2][l] != d) --ans;
		}else{
			tr[2][tr[1][r]] = tr[2][l] + d - tr[2][r];
			tr[1][tr[1][r]] = tr[1][tr[1][l]];
		}
	}
	ACH(ans == n ? "Yes\n" : "No\n");
}