#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
signed main() {
	int n, k; cin >> n >> k;
	string s; cin >> s;
	string t = s;
	string inf;
	rep(i, 10000)inf.push_back('z');
	reverse(t.begin(), t.end());
	rep(z, k - 1) {
		string s1 = s + t;
		string maxs = inf;
		rep(i, n) {
			string now;
			for (int j = i; j < i + n; j++)now.push_back(s1[j]);
			if (maxs > now)maxs = now;
		}
		s = maxs;
		t = maxs;
		reverse(s.begin(), s.end());
		int cnt = 0;
		rep(i, n)if (s1[i] == s1[0])cnt++;
		if (cnt == n)break;
		//cout << s << endl;
	}
	string s1 = s + t;
	string ans = inf;

	rep(i, n) {
		string now;
		for (int j = i; j < i + n; j++) {
			now.push_back(s1[j]);
		}
		if (now < ans)ans = now;
	}
	cout << ans << endl;
}