/*
ЗАПУСКАЕМ
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
 
using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { x = (x > y ? y: x);}
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { x = (x < y ? y: x);}
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define left left224
#define right right224
#define next next224
#define rank rank224
#define prev prev224
#define y1 y1224
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define files(FILENAME) read(FILENAME), write(FILENAME)
#define pb push_back
#define mp make_pair
using ll = long long;
const string FILENAME = "input";


int n, k;
string s;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //read(FILENAME); 
    cin >> n >> k;
    cin >> s;
    string t = s;
    reverse(all(t));
    string u = s + t;
    char ress = 'x';
    for (auto x: t) {
        chkmin(ress, x);
    }
    int mxl = 0;
    int curl = 0;
    for (auto x: u) {
        if (x == ress) {
            curl++;
        } else {
            curl = 0;
        }
        chkmax(mxl, curl);
    }
    int cur = mxl;
    for (int i = 0; i < k - 1; i++) {
        cur *= 2;
        if (cur > n) {
            break;
        }
    }
    if (cur >= n) {
        for (int i = 0; i < n; i++) {
            cout << ress;
        }
        cout << endl;
        return 0;
    }
    string ans = s;
    string u1 = u;
    for (int tt = 0; tt <= n; tt++) {
        s.clear();
        int fk = 0;
        int cs = 0;
        for (int i = tt; i < tt + n; i++) {
            s += u1[i];
            if (u1[i] == ress) {
                fk++;
            } else {
                fk = 0;
            }
            chkmax(cs, fk);
        }
        if (cs != mxl) {
            continue;
        }
        t = s;
        reverse(all(t));
        u = s + t;
       // cout << u << endl;
        for (int it = 2; it <= k; it++) {
            if (it == k) {
                int a = 0;
                int ok = 0;
                int pos = -1;
                for (int i = 0; i < sz(u); i++) {
                    if (u[i] == ress) {
                        a++;
                    } else {
                        a = 0;
                    }
                    if (a > ok) {
                        ok = a;
                        pos = i - ok + 1;
                    }
                }
                s.clear();
                for (int j = pos; j < pos + n; j++) {
                    s += u[j];
                }
            } else {
                int a = 0;
                int ok = 0;
                int pos = -1;
                for (int i = sz(u) - 1; i >= 0; i--) {
                    if (u[i] == ress) {
                        a++;
                    } else {
                        a = 0;
                    }
                    if (a > ok) {
                        ok = a;
                        pos = i + ok - 1 - n + 1;
                    }
                }
                s.clear();
                for (int j = pos; j < pos + n; j++) {
                    s += u[j];
                }
            }
            t = s;
            reverse(all(t));
            u = s + t;
        }
        chkmin(ans, s);
    }
    cout << ans << endl;
    return 0; 
}



Measured memory_bytes: 512