#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > adjlist[100005];
int inc[100005];
bitset<100005> vis;
int dist[100005];
bool flag=true;

void dfs(int v, int d) {
	if (dist[v]==-1) dist[v]=d;
	else if (dist[v]!=d) flag=false;
	//printf("%d %d\n", v, dist[v]);
	vis[v]=true;
	for (auto it:adjlist[v]) {
		if (!vis[it.first]) dfs(it.first, d+it.second);
		if (d+it.second!=dist[it.first]) flag=false;
	}
}

int main() {
	memset(dist,-1,sizeof(dist));
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i=0; i<m; i++) {
		int l,r,d;
		scanf("%d%d%d", &l, &r, &d);
		l--; r--;
		adjlist[l].push_back({r,d});
		inc[r]++;
	}
	for (int i=0; i<n; i++) {
		if (vis[i]||inc[i]) continue;
		dfs(i,0);
	}
	for (int i=0; i<n; i++) flag &= vis[i];
	printf("%s\n", flag?"Yes":"No");
}
