#include <bits/stdc++.h>
using namespace std;
int n, k;
char s[10004], res[10004], c = 'z';
int l[10004], len, mx, vis;

void cpy(int p) {
    for (int i = 1; i <= n; ++i) res[i] = s[p + i - 1];
}

void check(int p) {
    if (!vis) cpy(p), vis = 1;
    for (int i = 1; i <= n; ++i) {
        if (res[i] < s[p + i - 1]) return;
        if (res[i] > s[p + i - 1]) return cpy(p);
    }
}

int main() {
    scanf("%d%d%s", &n, &k, s + 1);
    for (int i = 1; i <= n; ++i) c = min(c, s[(n << 1) + 1 - i] = s[i]);
    if (k >= 15) {
        for (int i = 1; i <= n; ++i) putchar(c);
        return 0;
    }
    if (k == 1) {
        for (int i = 1; i <= n + 1; ++i) check(i);
        for (int i = 1; i <= n; ++i) putchar(res[i]);
        return 0;
    }
    for (int i = 1; i <= n + n; ++i)
        (s[i] == c) ? mx = max(mx, l[i] = l[i - 1] + 1) : 0;

    if ((len = mx << k - 1) >= n) {
        for (int i = 1; i <= n; ++i) putchar(c);
        return 0;
    }
    for (int i = 1; i <= n + mx; ++i)
        if (l[i] == mx) check(i - l[i] + 1);
    for (int i = 1; i <= len; ++i) putchar(c);
    for (int i = len + 1; i <= n; ++i) putchar(res[i - len + mx]);
    return 0;
}