#include <bits/stdc++.h>
using namespace std;
int n, k;
string s, tmp, res = "{";
int main() {
	cin >> n >> k >> s;
	tmp = s; reverse(s.begin(), s.end());
	s = tmp + s; --k;
	for (int i = 0; i < n * 2; ++i) {
		int cnt = 0;
		for (int j = i; j < n * 2; ++j)
			if (s[j] == s[i]) ++cnt;
			else break;
		if (i + cnt < n) continue;
		for (int j = 1; j <= k; ++j) {
			cnt *= 2; if (cnt >= n) break;
		}
		cnt = min(cnt, n);
		string tmp;
		for (int j = 1; j <= cnt; ++j) tmp += s[i];
		for (int j = 1; j <= n - cnt; ++j)
			tmp += s[i - j];
		res = min(res, tmp);
	}
	cout << res;
}
