#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &t) {
  t = 0;
  char ch = getchar();
  int f = 1;
  while ('0' > ch || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  do {
    (t *= 10) += ch - '0';
    ch = getchar();
  } while ('0' <= ch && ch <= '9');
  t *= f;
}
const int maxn = 10010;
char s[maxn], ch, ans[maxn], t[maxn];
bool cmp(char a[], char b[]) {
  int n = strlen(a + 1), m = strlen(b + 1);
  if (n != m) return n < m;
  for (int i = 1; i <= n; i++)
    if (a[i] != b[i]) return a[i] < b[i];
  return 0;
}
int n, k;
bool solve() {
  int cur = 0, len = 0, pos;
  for (int i = 1; i <= n; i++) {
    if (t[i] == ch)
      cur++;
    else
      cur = 0;
    if (cur >= len) len = cur, pos = i - cur + 1;
  }
  if (pos + len - 1 != n) return 0;
  for (int i = 2; i <= k && len < n; i++) {
    for (int j = n + 1; j <= n * 2; j++) t[j] = t[n - (j - n) + 1];
    if (i < k)
      for (int j = len + 1; j <= n + len; j++) t[j - len] = t[j];
    else
      for (int j = n - len + 1; j <= n * 2 - len; j++) t[j - n + len] = t[j];
    t[n + 1] = 0;
    len *= 2;
  }
  return 1;
}
int main() {
  read(n);
  read(k);
  scanf("%s", s + 1);
  ch = 'z';
  for (int i = 1; i <= n; i++) ch = min(ch, s[i]);
  if (k >= 15) {
    for (int i = 1; i <= n; i++) printf("%c", ch);
    printf("\n");
  } else {
    for (int i = n + 1; i <= n * 2; i++) s[i] = s[n - (i - n) + 1];
    for (int i = 1; i <= n * 2 + 1; i++) ans[i] = 'z' + 1;
    if (k == 1) {
      for (int i = 1; i <= n; i++) {
        for (int j = i; j <= i + n - 1; j++) t[j - i + 1] = s[j];
        if (cmp(t, ans)) {
          for (int j = 1; j <= n; j++) ans[j] = t[j];
          ans[n + 1] = 0;
        }
      }
      printf("%s\n", ans + 1);
      return 0;
    }
    for (int i = 1; i <= n; i++) {
      for (int j = i; j <= i + n - 1; j++) t[j - i + 1] = s[j];
      if (solve() && cmp(t, ans)) {
        for (int j = 1; j <= n; j++) ans[j] = t[j];
        ans[n + 1] = 0;
      }
    }
    printf("%s\n", ans + 1);
  }
  return 0;
}
