#include <bits/stdc++.h>
using namespace std;
int n, k;
char s[5005], t[5005], ss[10005], res[5005];
void check() {
  int len = 0;
  for (int i = 2; i < k; i++) {
    while (s[n - len] == s[n]) len++;
    for (int j = len + 1; j <= n + len; j++) {
      if (j <= n)
        t[j - len] = s[j];
      else
        t[j - len] = s[2 * n - j + 1];
    }
    for (int j = 1; j <= n; j++) s[j] = t[j];
  }
  while (s[n - len] == s[n]) len++;
  for (int i = n - len + 1; i <= 2 * n - len + 1; i++) {
    if (i <= n)
      t[i - (n - len)] = s[i];
    else
      t[i - (n - len)] = s[2 * n - i + 1];
  }
  for (int j = 1; j <= n; j++) s[j] = t[j];
  for (int i = 1; i <= n; i++) {
    if (res[i] == s[i]) continue;
    if (res[i] > s[i]) {
      for (int j = i; j <= n; j++) res[j] = s[j];
    }
    break;
  }
}
int main() {
  scanf("%d%d", &n, &k);
  scanf("%s", s + 1);
  char minn = 'z';
  for (int i = 1; i <= n; i++) minn = min(minn, s[i]);
  int l = 1;
  for (int i = 3; i <= k; i++) {
    l <<= 1;
    if (l > n) {
      for (int i = 1; i <= n; i++) putchar(minn);
      putchar('\n');
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) res[i] = 'z';
  for (int i = 1; i <= n; i++) ss[i] = s[i];
  for (int i = n + 1; i <= 2 * n; i++) ss[i] = s[2 * n - i + 1];
  for (int en = n; en <= 2 * n; en++) {
    if (ss[en] == minn) {
      int st = en - n + 1;
      for (int i = st; i <= en; i++) s[i - st + 1] = ss[i];
      if (k == 1) {
        for (int i = 1; i <= n; i++) {
          if (res[i] == s[i]) continue;
          if (res[i] > s[i]) {
            for (int j = i; j <= n; j++) res[j] = s[j];
          }
          break;
        }
      } else
        check();
    }
  }
  res[n + 1] = '\0';
  printf("%s\n", res + 1);
  return 0;
}
