#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < n; i++)
#define vi vector<int>
 
#define ll long long
#define vl vector<ll>
#define vll vector<vl>
 
const ll mod = 1000000007;
 
int main() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	char m='z';
	rep(i, s.size()) m=min(m, s[i]);
	if(k>=15)
    {
      rep(i, n) cout << m;
      cout << endl;
      return 0;
    }
 
	if(k==1)
	{
		string t1=s;
		reverse(t1.begin(), t1.end());
		s=(s+t1);
		rep(i, n)
		{
			t1=min(t1, s.substr(i, n));
		}
		cout << t1 << endl;
		return 0;
	}
 
	int st[5010], en[5010];
	int ind=0;
	rep(i, n)
	{
		if(s[i]==m)
		{
			if(i==0) st[ind]=i;
			else if(s[i-1]!=m) st[ind]=i;
			if(i==n-1)
			{
				en[ind]=i+1;
				ind++;
			}
			else if(s[i+1]!=m)
			{
				en[ind]=i+1;
				ind++;
			}
		}
	}
	//rep(i, ind) cout << st[i] << ' ' << en[i] << endl;
	int mx=0;
	rep(i, ind) mx=max(mx, en[i]-st[i]);
 
	int mlt=(int)(1<<(k-1));
 
	string ans=s;
 
	rep(i, ind)
	{
		if(en[i]<n)
		{
			string t0=s;
			reverse(t0.begin(), t0.end());
			t0=s+t0;
			string t1=t0.substr(n-st[i], n);
			string t2=t1;
			reverse(t2.begin(), t2.end());
			string t3=t2.substr(0, en[i]-st[i]);
			t2=t2.substr(en[i]-st[i], n-(en[i]-st[i]));
			rep(j, k-1) t3=t3+t3;
			t2=t3+t2;
			t2=t2.substr(0, n);
			ans=min(s, t2);
		}
		else
		{
			string t0=s;
			reverse(t0.begin(), t0.end());
			t0=s+t0;
			string t1=t0.substr(n-st[i], n);
			string t2=t1;
			reverse(t2.begin(), t2.end());
			string t3=t2.substr(0, en[i]-st[i]);
			t2=t2.substr(en[i]-st[i], n-(en[i]-st[i]));
			rep(j, k) t3=t3+t3;
			t2=t3+t2;
			t2=t2.substr(0, n);
			ans=min(s, t2);
		}
	}
 
 
 
	cout << ans << endl;