#include <iostream>
#include <algorithm>

using namespace std;

string v[5000];

int main(){
    int N, K;
    string S;
    cin >> N >> K;
    cin >> S;
    string V = S;
    reverse(S.begin(), S.end());
    string T = V+S;
    string M;
    for(int i = 0; i < N; i++){
        v[i] = T.substr(i, N);
        if(i == 0) M = v[i];
        else M = min(M, v[i]);
    }
    //sort(v, v+N);
    //cout << M << endl;
    char prev = M[0];
    int cnt = 1;
    for(int i = 1; i < N; i++){
        if(prev != M[i]){
            break;
        }
        cnt++;
    }
    int tmp = cnt;
    for(int i = 1; i < K; i++){
        tmp *= 2;
        if(tmp >= N){
            for(int i = 0; i < N; i++) cout << M[0];
            cout << endl;
            return 0;
        }
    }
    for(int i = 0; i < tmp; i++) cout << M[0];
    for(int i = cnt; tmp-cnt+i < N; i++) cout << M[i];
    cout << endl;
}