#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
const int MAXN = 100005;

int n, m, fa[MAXN]; LL val[MAXN];

int find(int x){
	if(fa[x] < 0) return x;
	int ret = find(fa[x]);
	val[x] += val[fa[x]];
	return fa[x] = ret;
}
int main(){
	int i, a, b, c, tmp;
	memset(fa, -1, sizeof(fa));
	scanf("%d%d", &n, &m);
	for(i = 1; i <= m; ++ i){
		scanf("%d%d%d", &a, &b, &c);
		if(find(a) != find(b)){
			val[tmp = find(a)] = val[b] - c - val[a];
			fa[tmp] = find(b);
		}else if(val[b] - val[a] != c){
			printf("No\n");
			return 0;
		}
	} printf("Yes\n");
	return 0;
}