#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    rep(i, min(k, 13+1)){ // log2(5000) < 13
        string t = s;
        reverse(all(t));
        s += t;
        reverse(all(s));
        string now = s.substr(0, n);
        REP(i, n)now = min(now, s.substr(i, n));
        reverse(all(now));
        s = now;
    }
    reverse(all(s));
    cout << s << endl;
}   
