#include <bits/stdc++.h>
using namespace std;

int n, k;
string s;

int main() {
    ios::sync_with_stdio(0);
    cin >> n >> k >> s;
    while (k--) {
        string lst = s, u = s;
        reverse(s.begin(), s.end()), u.append(s);
        for (int i = 0; i + n - 1 < u.length(); i++) {
            s = min(s, u.substr(i, s.length()));
        }
        if (k) reverse(s.begin(), s.end());
        if (s == lst) { cout << s << endl; return 0; }
    }
    cout << s << endl;
    return 0;
}