#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
const int inf = 1000 * 1000 * 1000;
const int mod = 998244353;
int n, k;
string s;
pair<pair<int, int>, int> p[N];
int R[N];
int main() {
  mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
  cin >> n >> k;
  cin >> s;
  k = min(k, 16);
  while (k--) {
    string t = s;
    reverse(t.begin(), t.end());
    string S = s + t;
    for (int i = 0; i <= 16; i++) {
      for (int j = 0; j < (int)S.size(); j++) {
        if (i == 0) {
          p[j].first = make_pair(S[j] - 'a', 0);
          p[j].second = j;
        } else {
          if (j + (1 << (i - 1)) >= (int)S.size()) {
            p[j].first = make_pair(R[j], -1);
            p[j].second = j;
          } else {
            p[j].first = make_pair(R[j], R[j + (1 << (i - 1))]);
            p[j].second = j;
          }
        }
      }
      sort(p, p + (int)S.size());
      int it = 0;
      for (int j = 0; j < (int)S.size(); j++) {
        ++it;
        pair<int, int> x = p[j].first;
        while (j < (int)S.size() && p[j].first == x) {
          R[p[j].second] = it;
          ++j;
        }
        --j;
      }
    }
    int mn = inf;
    int id;
    for (int i = 0; i < n; i++) {
      if (R[i] < mn) {
        mn = R[i];
        id = i;
      }
    }
    if (k == 0) {
      int it = 0;
      while (it < n) {
        s[it++] = S[id++];
      }
    } else {
      int it = n - 1;
      id = 2 * n - 1 - id;
      while (it >= 0) {
        s[it--] = S[id--];
      }
    }
  }
  cout << s << endl;
  return 0;
}
