#include <bits/stdc++.h>
using namespace std;
int n, k;
char ch[100006];
int l[100006];
string res, t;
void solve() {
  cin >> n >> k;
  scanf("%s", ch + 1);
  char c = 'z';
  for (int i = (1), iend = (n); i <= iend; ++i)
    ch[n + (n - i + 1)] = ch[i], c = min(c, ch[i]);
  n <<= 1;
  if (k == 1) {
    string res;
    for (int i = (1), iend = ((n >> 1)); i <= iend; ++i) {
      string t;
      for (int j = (i), jend = (i + (n >> 1) - 1); j <= jend; ++j) t += ch[j];
      if (res.empty() || res > t) res = t;
    }
    cout << res << endl;
    return;
  }
  if (k >= 15) {
    for (int i = (1), iend = (n >> 1); i <= iend; ++i) putchar(c);
    return;
  }
  int mx = 0;
  for (int i = (1), iend = (n); i <= iend; ++i) {
    if (ch[i] == c)
      l[i] = l[i - 1] + 1, mx = max(mx, l[i]);
    else
      l[i] = 0;
  }
  int len = (mx << k - 1);
  if (len >= (n >> 1)) {
    for (int i = (1), iend = (n >> 1); i <= iend; ++i) putchar(c);
    return;
  }
  for (int i = (1), iend = (n); i <= iend; ++i) {
    if (l[i] == mx) {
      t.clear();
      if (i + (n >> 1) - len > n) break;
      for (int j = (i + 1), jend = (i + (n >> 1) - len); j <= jend; ++j)
        t.push_back(ch[j]);
      if (res.empty() || res > t) res = t;
    }
  }
  for (int i = (1), iend = (len); i <= iend; ++i) putchar(c);
  for (auto& t : res) putchar(t);
}
signed main() { solve(); }
