use strict;
use warnings;

my ($l, $t, $input, $target, @a_target, $n, $r, $min, @cmp);
while(<>){
	chomp;
	($l, $t) = split(/ /, $_) if($. == 1);
	$input = $_ if($. == 2);
}

$target = $input . reverse($input);
for my $i (1 .. $t){
	@a_target = split(//, $target);
	$min = substr(join("",sort {$a cmp $b}(@a_target)),1,1);
	@cmp = ();
	if($i == $t){
		for my $n (0 .. $#a_target - $l){
			next if($a_target[$n] ne $min);
			push(@cmp, join("", @a_target[$n .. $n + $l - 1]));
		}
		@cmp = sort(@cmp);
		$r = $cmp[0];
	}
	else{
		for my $n ($l - 1 .. $#a_target){
			next if($a_target[$n] ne $min);
			push(@cmp, join("", reverse(@a_target[$n - $l + 1 .. $n])));
		}
		@cmp = sort(@cmp);
		$target = reverse($cmp[0]) . $cmp[0];
	}
}

print $r;
