#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int main()
{
    int N, K;
    string S;
    cin >> N >> K >> S;
    K = min(K, 13);
    string ret = S;

    for (int i = 0; i < N; i++)
    {
        string T = S;
        for (int k = 0; k < K; k++)
        {
            string Tinv = T;
            reverse(Tinv.begin(), Tinv.end());
            T += Tinv;
            if (k == 0) T = T.substr(N - i, N);
            else if (k == K - 1)
            {
                int j = N - 1;
                while (j >= 0 and T[j] == T[N - 1]) j--;
                T = T.substr(j + 1, N);
            }
            else
            {
                int j = N - 1;
                while (j < 2 * N and T[j] == T[N - 1]) j++;
                T = T.substr(j - N, N);
            }
        }
        ret = min(ret, T);
    }
    cout << ret << endl;
}
