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

int n, m, d[100005], p[100005];
vector<int> c[100005];

int Find (int X) {
	if(p[X] == X) return X;
	return p[X] = Find(p[X]);
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) {
		p[i] = i;
		c[i].push_back(i);
	}
	while(m--) {
		int L, R, C;
		scanf("%d%d%d",&L,&R,&C);
		int LL = Find(L), RR = Find(R);
		if(LL == RR) {
			if(d[R] - d[L] != C) {
				puts("No");
				return 0;
			}
			continue;
		}
		if(c[LL].size() < c[RR].size()) {
			swap(LL, RR);
			swap(L, R);
			C *= -1;
		}
		int D = d[L] + C - d[R];
		for(auto &T : c[RR]) {
			c[LL].push_back(T);
			d[T] += D;
		}
		p[RR] = LL;
		c[RR].clear();
	}
	puts("Yes");
}
