//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define pb push_back//also for STRING

#define MAX_N 100000

struct edge{
	int to,cost;
};

int d[MAX_N];
vector<edge> g[MAX_N];
bool f[MAX_N];

bool dfs(int v){
	f[v]=true;
	for(int j=0;j<g[v].size();++j){
		int w=g[v][j].to;
		if(f[w]){
			if(d[w]!=d[v]+g[v][j].cost) return false;
			continue;
		}
		d[w]=d[v]+g[v][j].cost;
		if(!dfs(w)) return false;
	}
	return true;
}

int main(){
	int n,m;
	scanf("%d %d",&n,&m);
	while(m-- > 0){
		int l,r,d;
		scanf("%d %d %d",&l,&r,&d);
		g[--l].pb((edge){--r,d});
		g[r].pb((edge){l,-d});
	}
	fill(f,f+n,false);
	for(int v=0;v<n;++v){
		if(!dfs(v)){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}