($N,$M) =split(" ",<STDIN>);
for($i=0;$i<$M;$i++) {
	($L,$R,$D)=split(" ",<STDIN>);
	$L--;$R--;
	push @L,$L;
	push @R,$R;
	push @D,$D;
	$C{$L}{$R}=$#D;
	$C{$R}{$L}=$#D;
}

$m=0;
while ($m<$M) {
	$M{$m}=1;
	push @M,$m;
	$L=$L[$m];$R=$R[$m];
	push @K,$L;$K{$L}=1;
	push @K,$R;$K{$R}=1;
	$x{$L} = 0;
	$x{$R} = $D[$m];
	
	while ($#K>=0){
		$i=pop(@K);
		foreach $j ( keys %{$C{$i}} ) {
			$n=$C{$i}{$j};
			next if ($M{$n});
			$M{$n}=1;
			push @M,$n;
			if (!exists($K{$j})) {
				push @K,$j;$K{$j}=1;
			}
		}
	}
	$m++;
	for(;$M{$m}!=0;$m++){}
}

for($i=0;$i<=$#M;$i++){
	$m=$M[$i];$L=$L[$m];$R=$R[$m];
	if ( exists($x{$L}) ) {
		if ( exists($x{$R}) ) {
			if ($x{$R} != $x{$L}+$D[$m]) {
				print "No";
				exit;
			}
		} else {
			$x{$R} = $x{$L}+$D[$m];
		}
	} else {
		$x{$L} = $x{$R}-$D[$m];
	}
}


print "Yes";
