#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 10010;
int n,k,cnt[N];
char s[N],t[N];

inline int lg(int n){
	int x=1,ret=0;
	while (x<n) x<<=1,++ret;
	return ret;
}

int main(){
	scanf("%d%d%s",&n,&k,s+1);
	int mn=1e9;
	For(i,1,n) mn=min(mn,(int)s[i]);
	if (k>1+lg(n)){
		For(i,1,n) printf("%c",mn);
		return 0;
	}
	while (k>1){
		For(i,1,n) t[i]=s[i];
		For(i,1,n) t[n+i]=s[n-i+1];
		For(i,1,n*2) if (mn==t[i]) cnt[i]=cnt[i-1]+1;
		int pos=n;
		For(i,n+1,n*2){
			if (cnt[i]>cnt[pos]) pos=i;
			else if (cnt[i]==cnt[pos]){
				bool flag=0;
				For(j,1,n-cnt[i]) if (t[pos-cnt[i]-j+1]!=t[i-cnt[i]-j+1]){
					if (t[pos-cnt[i]-j+1]>t[i-cnt[i]-j+1]) flag=1;
					break;
				}
				if (flag) pos=i; 
			}
		}
		For(i,1,n) s[i]=t[pos-n+i];
		--k;
	}
	For(i,1,n) t[i]=s[i];
	For(i,1,n) t[n+i]=s[n-i+1];
	int pos=n;
	For(i,n+1,n*2){
		bool flag=0;
		Dow(j,n,1) if (t[pos-j+1]!=t[i-j+1]){
			if (t[pos-j+1]>t[i-j+1]) flag=1;
			break;
		}
		if (flag) pos=i;
	}
	For(i,1,n) s[i]=t[pos-n+i];
	For(i,1,n) printf("%c",s[i]);
}