#include<cstdio>
#include<algorithm>
#include<cstring>
#define rep(i, s, t) for(i = s; i <= t; ++i)
#define dep(i, s, t) for(i = s; i >= t; --i)

using namespace std;

const int N = 1e5 + 10;
int n, m; bool ans = 1;
int pos[N];
struct edge{int ed, v, ne;} e[N<<1]; int he[N], in[N], en;

void ins(int a, int b, int c) {
	e[++en].ed = b; e[en].v = c; e[en].ne = he[a]; he[a] = en; ++in[b];
}

void dfs(int u) {
	for(int i = he[u], v; i; i = e[i].ne) {
		v = e[i].ed;
		if(!pos[v]) {
			pos[v] = pos[u] + e[i].v;
			dfs(v);
		} else 
			if(pos[u] + e[i].v != pos[v]) ans = 0;
	}
}

int main() {
	int i, x, y, z;
	scanf("%d%d", &n, &m);
	rep(i, 1, m) {scanf("%d%d%d", &x, &y, &z); ins(x, y, z);}
	rep(i, 1, n) if(!in[i]) {pos[i] = 1; dfs(i);}
	rep(i, 1, n) if(!pos[i]) ans = 0;
	if(ans) puts("Yes"); else puts("No");
	return 0;
}