#include<bits/stdc++.h>
#define N 10010
#define mo 1000010009
using namespace std;
int n,k,s[N],sm[N],pw[N];
bool eq(int l,int r,int L,int R){
	return 1ll*(sm[R]-sm[L]+mo)*pw[l]%mo==1ll*(sm[r]-sm[l]+mo)*pw[L]%mo;
}
int main(){
	scanf("%d %d\n",&n,&k);
	for(int i=1;i<=n;++i)s[n+n+1-i]=s[i]=getchar()-96;
	pw[0]=1;for(int i=1;i<=n+n;++i)pw[i]=31ll*pw[i-1]%mo;
	for(int i=1;i<=n+n;++i)sm[i]=(sm[i-1]+1ll*pw[i]*s[i])%mo;
	int ps=n;
	for(int i=n+1;i<=n+n;++i){
		int l=0;
		for(int j=12;j+1;--j)if(l+(1<<j)<=n)
			if(eq(ps-l-(1<<j),ps,i-l-(1<<j),i))l+=1<<j;
		if(l<n&&s[i-l]<s[ps-l])ps=i;
	}
	--k;
	while(k--){
		for(int i=1;i<=n;++i)s[i]=s[ps-n+i];
		for(int i=1;i<=n;++i)s[n+n+1-i]=s[i];
		int Q=1;
		for(int i=1;i<n;++i)if(s[i]^s[i+1])Q=0;
		if(Q)break;
		ps=n;while(s[ps+1]==s[ps])++ps;
	}ps=n+1;
	for(int i=1;i<=n+n;++i)sm[i]=(sm[i-1]+1ll*pw[i]*s[i])%mo;
	for(int i=1;i<=n;++i){
		int l=0;
		for(int j=12;j+1;--j)if(l+(1<<j)<=n)
			if(eq(ps+l+(1<<j)-1,ps-1,i+l+(1<<j)-1,i-1))l+=1<<j;
		if(l<n&&s[i+l]<s[ps+l])ps=i;
	}
	for(int i=1;i<=n;++i)putchar(s[ps+i-1]+96);
}