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

int n, p[100010], d[100010];
int getf(int x){
	if(p[x] == x)return x;
	getf(p[x]);
	int parent = p[x];
	p[x] = p[parent];
	d[x] = d[x] + d[parent];
	return p[x];
}

int main(){
	int n, m;
	scanf("%d%d" , &n , &m);
	for(int i = 1 ; i <= n ; i++)
		p[i] = i, d[i] = 0;

	bool invalid = false;

	for(int i = 1 ; i <= m ; i++){
		int l, r, dd;
		scanf("%d%d%d" , &l , &r , &dd);

		if(l == r){
			if(dd == 0)continue;
			else{
				invalid = true;
				continue;
			}
		}

		int pl = getf(l), pr = getf(r);

		if(pl == pr){
			if(d[r] - d[l] == dd){
				continue;
			}
			else{
				invalid = true;
			}
		}
		else{
			p[pr] = pl;
			d[pr] = dd - d[r] + d[l];
		}
	}

	if(invalid){
		puts("No");
		return 0;
	}

	puts("Yes");

	return 0;
}