#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
//#define int long long
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long double ld;
typedef long long ll;
#define X first
#define Y second
#define all(o) o.begin(), o.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0), cin.tie(0)

int gcd(int x,int y){ return (!y ? x : gcd(y, x%y)); }
const int maxn = 5000 * 10;
int num[maxn];
int32_t main(){
	IOS;
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	char c = 'z';
	for(int i=0; i<n; i++)
		c = min(c, s[i]);
	string org = s;
	string ans;
	for(int i=0; i<n; i++)
		ans += 'z';
	if(k >= 14){
		ans = "";
		for(int i=0; i<n; i++)
			ans += c;
		cout << ans << endl;
		return 0;
	
	}
	int ted = 0;
	int mx = -1;
	for(int i=0; i<n; i++){
		if(s[i] == c)
			ted++;
		else
			ted = 0;
		if(i >= n - 1)
			mx = max(mx, ted);
		num[i] = ted;
	}
	for(int en = n; en <= 2 * n; en++){
		s = org;
		string rev = s;
		reverse(all(rev));
		string st = s + rev;
			
		s = st.substr(en - n, n);
		ans = min(ans, s);
		//cout << "WTF\n" << s << endl;
		if(num[i - 1] != ted)
			continue;
		for(int it=1; it<k; it++){
			//cout << ":D" << it << endl;
			int cnt = 0;
			rev = s;
			reverse(all(rev));
			st = s + rev;
			int mx = -1, who = -1;
			
			if(it == k - 1){
				for(int i=0; i<=n; i++)
					ans = min(ans, st.substr(i, n));
			}
			else{
				for(int i=0; i<2*n; i++){
					if(st[i] == c)
						cnt++;
					else
						cnt = 0;
					if(i >= n - 1 && cnt > mx){
						mx = cnt;
						who = i + 1;
					}
				}
				s = st.substr(who - n, n);
			}
			
		}
		ans = min(ans, s);
		
	}
	cout << ans << endl;
}