#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void rd(T &x) {
  x = 0;
  char c = getchar();
  int f = 1;
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 - '0' + c, c = getchar();
  x *= f;
}
const int N = 5010;
char str[N << 1];
int n, k;
char ch;
int len[N << 1];
int ansl, ansr;
int anslen;
void upd(int l, int r) {
  if (!ansl) return (void)(ansl = l, ansr = r);
  for (int i = 0; i < anslen; ++i)
    if (str[r - i] != str[ansr - i]) {
      if (str[r - i] < str[ansr - i]) ansr = r, ansl = l;
      return;
    }
}
int main() {
  rd(n), rd(k);
  scanf("%s", str + 1);
  ch = 127;
  for (int i = 1; i <= n; ++i) {
    str[n + i] = str[n - i + 1];
    ch = min(ch, str[i]);
  }
  int mxlen = 0;
  for (int i = 1; i <= n * 2; ++i) {
    if (str[i] == ch)
      len[i] = len[i - 1] + 1;
    else
      len[i] = 0;
    mxlen = max(mxlen, len[i]);
  }
  if (mxlen * (1ll << (min(k - 1, 20))) >= n) {
    for (int i = 1; i <= n; ++i) putchar(ch);
    return 0;
  }
  int _len = mxlen * (1 << k - 1);
  anslen = n - _len;
  if (k == 1) {
    int ansp = 1;
    for (int i = 2; i <= n + 1; ++i) {
      for (int j = 0; j < n; ++j)
        if (str[i + j] != str[ansp + j]) {
          if (str[i + j] < str[ansp + j]) ansp = i;
          break;
        }
    }
    for (int j = 0; j < n; ++j) putchar(str[ansp + j]);
    return 0;
  }
  for (int i = 1; i <= n + 1; ++i) {
    if (len[i + n - 1] < mxlen) continue;
    upd(i + n - _len / 2 - anslen, i + n - 1 - _len / 2);
  }
  for (int i = 1; i <= _len; ++i) putchar(ch);
  for (int i = ansr; i >= ansl; --i) putchar(str[i]);
  return 0;
}
