#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
string test[345678];
signed main() {
	int n, k, a = 1; string s; char mi = 'z'; cin >> n >> k >> s;
	for (int h = 0; h < n; h++) { mi = min(mi, s[h]); }
	if (s[n - 1] == mi) { a = 2; }
	for (int h = 2; h <= min(k, (long long)15); h++) {
		a *= 2;
		if (a >= n) { 
			for (int i = 0; i < n; i++) { cout << mi; } cout << endl; return 0;
		}
	}
	string r = s;
	for (int h = 0; h < k; h++) {
		string t = r; reverse(r.begin(), r.end()); t += r;
		for (int i = 0; i < n + 5; i++) { test[i] = ""; }
		if (h == k - 1) {
			for (int i = 0; i <= n; i++) {
				for (int j = i; j < i + n; j++) {
					test[i] += t[j];
				}
			}
			sort(test, test + n + 1); 
			cout << test[0] << endl; return 0;
		}
		else {
			reverse(t.begin(), t.end());
			for (int i = 0; i <= n; i++) {
				for (int j = i; j < i + n; j++) {
					test[i] += t[j];
				}
			}
			sort(test, test + n + 1); r = test[0];
			reverse(r.begin(), r.end());
		}
	}
	return 0;
}