#include <cstdio>
#include <vector>
#include <cstdlib>
#define N 100005
int n, m, l, r, d, v[N], w[N];
std::vector<int> g[N], h[N];

void f(int p, int q) {
	if(v[p]) {
		if(q != w[p]) {puts("No"); exit(0);}
		return;
	}
	v[p] = 1;
	w[p] = q;
	for(int i=0; i<g[p].size(); i++) {
		f(g[p][i], q + h[p][i]);
	}
}

int main() {
	scanf("%d%d", &n, &m);
	while(m--) {
		scanf("%d%d%d", &l, &r, &d);
		g[l].push_back(r);
		g[r].push_back(l);
		h[l].push_back(d);
		h[r].push_back(-d);
	}
	for(int i=1; i<=n; i++) {
		if(!v[i]) f(i, 0);
	}
	puts("Yes");
	return 0;
}