#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;
	string T = S;
	reverse(T.begin(), T.end());
	S += T;

	char mn = 'z';
	for (int i = 0; i < N; i++) {
		mn = min(mn, S[i]);
	}
	vector<string> res;
	for (int i = 0; i <= N; i++) {
		T = "";
		for (int j = 0; j < N; j++) {
			T.push_back(S[i + j]);
		}
		res.push_back(T);
	}
	if (K > 30) {
		K = 30;
	}

	if (K > 1) {
		for (int i = N; i < 2 * N; i++) {
			if (S[i] == mn && (i == 2 * N - 1 || S[i + 1] != mn)) {
				int j = i;
				for (;; j--) {
					if (j == -1 || S[j] != mn)break;
				}

				T = "";
				for (int k = 0; k < min(N, (i - j) << (K - 1)); k++) {
					T.push_back(mn);
				}
				for (; j >= 0; j--) {
					if (T.size() == N)break;
					T.push_back(S[j]);
					
				}
				if (T.size() == N) {
					res.push_back(T);
				}
			}
		}
	}
	sort(res.begin(), res.end());


	cout << res[0] << endl;
}