#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, k; cin >> n >> k;
	string s, t; cin >> s;
	t = s; reverse(t.begin(), t.end());
	s += t;
	struct opt {
		int start;
		int size;
		char c;
	};
	string ans(n, 'z');
	if(k == 1){
		for(int i = 0; i <= n; i++){
			string now = s.substr(i, n);
			if(now < ans) ans = now;
		}
		cout << ans << endl;
		return 0;
	}
	for(int i = 0; i <= n; i++){
		opt now = {i, 0, s[i + n - 1]};
		for(int j = i + n - 1; j >= i && s[j] == now.c; j--, now.size++);
		int first_off = i + n - 1 - now.size;
		for(int j = 0; j < k - 2 && now.size < n; j++){
			now.size *= 2;
		}
		string here;
		int len_here = 0;
		for(int j = 0; len_here < n && j < now.size; j++){
			here.push_back(now.c);
			len_here++;
		}
		for(int j = first_off; len_here < n && j >= i; j--){
			here.push_back(s[j]);
			len_here++;
		}
		reverse(here.begin(), here.end());
		string up = here;
		reverse(up.begin(), up.end());
		here += up;
		int p = n - 1;
		while(p >= 0 && here[p] == here[n - 1]) p--;
		p++;
		string tr = here.substr(p, n);
		if(tr < ans) ans = tr;
	}
	cout << ans << endl;
	return 0;
}
