#include <bits/stdc++.h>
using namespace std;
const int N = 20000;
int n, m;
char Is[N + 5], ReS[N + 5], It[N + 3], Ns[N + 3], Nans[N + 3];
int main() {
  scanf("%d%d%s", &n, &m, Is + 1);
  strcpy(ReS + 1, Is + 1);
  reverse(ReS + 1, ReS + 1 + n);
  strcat(Is + 1, ReS + 1);
  m--;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < n; j++) It[j + 1] = Is[j + i];
    It[n + 1] = It[n];
    int Vlen = 0;
    for (int j = n; j >= 1; j--)
      if (It[j] == It[j + 1])
        Vlen++;
      else
        break;
    int logf = ceil(log2(ceil((double)n / Vlen)));
    if (m >= logf) {
      for (int j = 1; j <= n; j++) Ns[j] = It[n];
    } else {
      int k = n - Vlen;
      for (int j = 1; j <= Vlen * (1 << m); j++) Ns[j] = It[n];
      for (int j = 1; j + Vlen * (1 << m) <= n; j++)
        Ns[j + Vlen * (1 << m)] = It[k--];
    }
    Ns[n + 1] = '\0';
    if (Nans[1] == '\0')
      strcpy(Nans + 1, Ns + 1);
    else if (strcmp(Nans + 1, Ns + 1) > 0)
      strcpy(Nans + 1, Ns + 1);
  }
  printf("%s\n", Nans + 1);
  return 0;
}
