use strict;
use warnings;

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

$target = $input . join("", reverse(split(//,$input)));
for my $i (1 .. $t){
	$r = "";
	$n = 0;
	@a_target = split(//, $target);
	if($i == $t){
		while(1){
			$n = index($target, "a", $n);
			last if($n == -1);
			if($l - $n >= 0){
				$r = join("", @a_target[$n .. $n + $l - 1]) if(join("", @a_target[$n .. $n + $l - 1]) lt $r or $r eq "");
			}
			$n++;
		}
	}
	else{
		while(1){
			$n = index($target, "a", $n);
			last if($n == -1);
			if($n + 1 >= $l){
				$r = join("", reverse(@a_target[$n - $l + 1 .. $n])) if(join("", reverse(@a_target[$n - $l + 1 .. $n])) gt $r or $r eq "");
			}
			$n++;
		}
		$target = $r . join("", reverse(split(//,$r)));
	}
}

print $r;
