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

int n, k;

string ans, a;

string solve (string &S) {
	if(k == 1) return S;
	char L = S.back();
	int C = 0;
	while(S.back() == L) {
		S.pop_back();
		C++;
	}
	C = min(n, C*(1<<min(k-1, 13)));
	string R;
	while(C--) R.push_back(L);
	while(R.size() < n) {
		R.push_back(S.back());
		S.pop_back();
	}
	return R;
}

int main()
{
	ans.push_back('z'+1);
	cin >> n >> k >> a;
	string b = a;
	reverse(b.begin(), b.end());
	a += b;
	for(int i=0;i<=n;i++) {
		string T = a.substr(i, n);
		ans = min(ans, solve(T));
	}
	cout << ans << endl;
}
