#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=int(b); i++)
#define pb push_back
#define mp make_pair
#define v first
#define w second
using namespace std;
typedef pair<int,int> pii;

const int maxn = 200009, INF = 2e9;
int d[maxn], q[maxn], l, r, a, b, c, n, m, u;
vector<pii> e[maxn];

void bfs(int s) {
	l = r = 0; q[r++] = s; d[s] = 0;
	while (l < r) {
		u = q[l++];
		for (auto k : e[u])
			if (d[k.v] >= INF) {
				d[k.v] = d[u] + k.w;
				q[r++] = k.v;
			}
			else if (d[u] + k.w != d[k.v]) {
				puts("No"); exit(0);
			}
	}
}

int main() {
	scanf("%d%d", &n, &m);
	rep (i, 1, m) {
		scanf("%d%d%d", &a, &b, &c);
		e[a].pb(mp(b, c)); e[b].pb(mp(a, -c));
	}
	memset(d, 0x7f, sizeof d);
	rep (i, 1, n)
		if (d[i] >= INF) bfs(i);
	puts("Yes");
	return 0;
}