#include <iostream>
#include <algorithm>

using namespace std;

int n, bestPos;
string s;

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

int main() {
    int k;
    cin >> n >> k >> s;
    
    if (k > 100 || n >> k == 0) {
        char mi = 'z';
        for (auto c:s)mi = min(mi, c);
        cout << string(n, mi) << endl;
        return 0;
    }

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

        bestPos = 0;
        for (int j = 0; j <= n; j++) {
            if (compare(j, i != k - 1))bestPos = j;
        }

        string best = s.substr(bestPos, n);
        s = best;
    }

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