#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF=1e18;
const ll mod=1e9+7;

int main(){
    ll n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    string t=s;
    reverse(t.begin(),t.end());
    s+=t;
    k--;
    if(k==0){
        vector<ll> a(2*n);
        rep(i,2*n){
            ll v=s[i]-'a';
            a[i]=v;
        }
        vector<ll> dp(2*n);
        for(ll i=2*n-1;i>=0;i--){
            if(i==2*n-1) dp[i]=1;
            else{
                if(a[i]==a[i+1]){
                    dp[i]=dp[i+1]+1;
                }
                else{
                    dp[i]=1;
                }
            }
        }
        vector<string> pre;
        ll num=INF;
        ll cnt=0;
        rep(i,2*n){
            if(a[i]<num){
                num=a[i];
                cnt=dp[i];
            }
            if(a[i]==num){
                cnt=max(cnt,dp[i]);
            }
        }
        rep(i,2*n){
            if(a[i]==num && dp[i]==cnt){
                if(i+n-1<=2*n-1){
                    pre.push_back(s.substr(i,n));
                }
            }
        }
        sort(pre.begin(),pre.end());
        cout << pre[0] << endl;
        return 0;
    }
    
    
    vector<ll> a(2*n);
    rep(i,2*n){
        ll v=s[i]-'a';
        a[i]=v;
    }
    vector<ll> dp(2*n);
    rep(i,2*n){
        if(i==0) dp[i]=1;
        else{
            if(a[i]==a[i-1]){
                dp[i]=dp[i-1]+1;
            }
            else{
                dp[i]=1;
            }
        }
    }
    vector<string> pre;
    ll num=INF;
    ll cnt=0;
    rep(i,2*n){
        if(a[i]<num){
            num=a[i];
            cnt=dp[i];
        }
        if(a[i]==num){
            cnt=max(cnt,dp[i]);
        }
    }
    rep(i,2*n){
        if(a[i]==num && dp[i]==cnt){
            if(i>=n-1){
                pre.push_back(s.substr(i-n+1,n));
            }
        }
    }
    vector<pair<string,ll>> x;
    ll m=pre.size();
    rep(i,m){
        string y=pre[i].substr(0,n-cnt);
        reverse(y.begin(),y.end());
        x.push_back({y,i});
    }
    sort(x.begin(),x.end());
    string u=pre[x[0].se];
    //cout  << u << endl;
    ll val=cnt;
    bool inf=false;
    rep(i,k){
        val*=2;
        if(val>=n){
            inf=true;
            break;
        }
    }
    char c='a'+num;
    //cout << val << endl;
    if(inf){
        
        rep(i,n){
            cout << c;
        }
        cout << endl;
    }
    
    else{
        string ans="";
        rep(i,n){
            if(i<n-val){
                ans+=u[i+val-cnt];
            }
            else{
                ans+=c;
            }
        }
        reverse(ans.begin(),ans.end());
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 16068