#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair

using namespace std;

const int N = 200050;

int vis[N], a[N], L[N], R[N], D[N];
int n, m;
vector<pair<int, int> > g[N];

void dfs(int u){
	for(auto p : g[u]){
		if (vis[p.first]) continue;
		vis[p.first] = 1;
		a[p.first] = a[u] + p.second;
		dfs(p.first);
	}
}

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; ++i){
		scanf("%d%d%d", &L[i], &R[i], &D[i]);
		g[L[i]].pb(mp(R[i], D[i]));
		g[R[i]].pb(mp(L[i], -D[i]));
	}
	for(int i = 1; i <= n; ++i) if (!vis[i]){
		vis[i] = 1;
		dfs(i);
	}
	for(int i = 1; i <= m; ++i) if (a[L[i]] + D[i] != a[R[i]]){
		puts("No");
		return 0;
	}
	puts("Yes");
	return 0;
}