#include <iostream>
#include <algorithm>

using namespace std;

int n;
string best;

bool compare(string x, bool reversed) {
    for (int i = 0; i < n; i++) {
        if (!reversed && x[i] != best[i])return x[i] < best[i];
        if (reversed && x[n - 1 - i] != best[n - 1 - i])return x[n - 1 - i] < best[n - 1 - i];
    }
    return true;
}

int main() {
    int k;
    string s;
    cin >> n >> k >> s;

    for (int i = 0; i < k; i++) {
        string t = s;
        reverse(t.begin(), t.end());
        s += t;

        best = string(n, 'z');
        for (int j = 0; j <= n; j++) {
            string now = s.substr(j, n);
            if (compare(now, i != k - 1)) best = now;
        }

        if (best == s.substr(0, n)) {
            cout << best << endl;
            return 0;
        }
        s = best;
    }

    cout << s << endl;
    return 0;
}