// Remember...

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxn=5010,mod=998244353;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie();

    int n,k; cin>>n>>k;
    string s; cin>>s;
    
    k=min(k,15);

    string ss=s, ans=s, tmp;
    reverse(ss.begin(),ss.end());
    ss=s+ss;
    
    for(int i=0;i<=n;i++){
	s=ss.substr(i,n);

	if(k==1){
	    ans=min(ans,s);
	    continue;
	}
	
	int cnt1=0,cnt2=0;
	while(cnt1<n && s[n-1-cnt1]==s.back()) cnt1++;
	cnt2=min(n, cnt1<<(k-1));
	tmp="";
	for(int i=0;i<cnt2;i++)
	    tmp+=s.back();
	if(cnt2<n){
	    tmp+=s.substr(cnt2-cnt1,n-cnt2);
	    reverse(tmp.begin()+cnt2,tmp.end());
	}
	ans=min(ans,tmp);
    }
    return cout<<ans<<endl,0;   
}
// Deathly mistakes:
//  * Read the problem carefully.
//  * Check maxn.
//  * Overflows.


// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
