#include<bits/stdc++.h>
using namespace std;

int N , K , L , mx; string S , T; char mn = 127;

string work(int pos){
	pos = 2 * N - pos - 1;
	int len = L; for(int i = 1 ; i < K ; ++i) len <<= 1;
	return string(len , mn) + string(T , pos + mx , N - len);
}

int main(){
	cin >> N >> K >> S; T = S;
	reverse(T.begin() , T.end()); T = S = S + T;
	reverse(T.begin() , T.end());
	for(int i = 0 ; i < (int)S.size() ; ++i) mn = min(mn , S[i]);
	for(int i = 0 ; i < (int)S.size() ; ++i) mx = max(mx , L = S[i] == mn ? L + 1 : 0);
	L = mx;
	for(int i = 1 ; i < K && L < N ; ++i) L <<= 1;
	if(L >= N){cout << string(N , mn); return 0;}
	string ans; L = 0;
	for(int i = 0 ; i < (int)S.size() ; ++i){
		L = S[i] == mn ? L + 1 : 0;
		if(i >= N && L == mx){string T = work(i); if(ans.empty() || ans > T) ans = T;}
	}
	cout << ans;
	return 0;
}