#include <bits/stdc++.h>

int main(){
    using namespace std;

    unsigned long N, K;
    char s[5000];
    scanf("%lu%lu %s", &N, &K, s);
    string S(s, s + strlen(s));

    string T(S.begin(), S.end());
    T += string(S.rbegin(), S.rend());
    for(unsigned long i = 0; i < N; ++i)S = min(S, string(T.begin() + i, T.begin() + i + N));
    unsigned long k{static_cast<unsigned long>(find_if_not(S.begin(), S.end(), [&S](auto i){return i == S[0];}) - S.begin())};
    --K;
    return 0;
    unsigned long l = K > 13 ? N : min(N, (k << K) - k);
    string A(l, S[0]);
    A += string(S.begin(), S.begin() + N - A.size());

    puts(A.data());

    return 0;
}