#include <bits/stdc++.h>
using namespace std;
int n, k, len[10050];
char str[10050];
string as;
bool vis;
int main() {
  scanf("%d%d%s", &n, &k, str + 1);
  int minn = 998244353;
  for (int i = 1; i <= n; ++i)
    minn = min(minn, (int)(str[n * 2 + 1 - i] = str[i]));
  if (k >= 15) {
    for (int i = 1; i <= n; ++i) putchar(minn);
    return 0;
  }
  if (k == 1) {
    for (int i = 1; i <= n + 1; ++i) {
      string s = "";
      for (int j = i; j <= i + n - 1; ++j) s = s + str[j];
      if (!vis) {
        vis = 1;
        as = s;
      } else if (s < as)
        as = s;
    }
    cout << as << endl;
    return 0;
  }
  int maxn = 0;
  for (int i = 1; i <= 2 * n; ++i)
    len[i] = (str[i] == minn ? len[i - 1] + 1 : 0), maxn = max(maxn, len[i]);
  int as_len = maxn << k - 1;
  if (as_len >= n) {
    for (int i = 1; i <= n; ++i) putchar(minn);
    return 0;
  }
  for (int i = n; i <= 2 * n; ++i) {
    if (len[i] == maxn) {
      string s = "";
      for (int j = i; j >= i - n + 1; --j) s = s + str[j];
      if (!vis) {
        vis = 1;
        as = s;
      } else if (s < as)
        as = s;
    }
  }
  for (int i = 1; i <= as_len; ++i) putchar(minn);
  int cur = maxn;
  while (as_len < n) {
    putchar(as[cur++]);
    as_len++;
  }
  return 0;
}
