<?php
fscanf(STDIN, "%d %d", $n, $m);

$links = [];
$dists = [];
for($i = 0; $i < $m; $i++){
	list($l, $r, $d) = explode(' ', fgets(STDIN));
	$links[$l][] = [$r,  $d];
	$links[$r][] = [$l, -$d];
}

for($i = 0; $i < $n; $i++){
	if(isset($dists[$i]))continue;
	if(!dfs($i, 0)){
		echo "No\n";
		exit;
	}
}
echo "Yes\n";

function dfs($i, $dist){
	global $dists;
	global $links;
	if(isset($dists[$i]))return $dists[$i] == $dist;
	$dists[$i] = $dist;
	if(!isset($links[$i]))return true;
	foreach($links[$i] as $link){
		if(!dfs($link[0], $dist + $link[1]))return false;
	}
	return true;
}

