#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5005;
struct Node {
  int ch[26];
  int len, par;
} node[MAXN << 2];
int n, k, id, lst;
char s[MAXN];
void extend(int c) {
  int p = lst, np = ++id;
  node[np].len = node[p].len + 1;
  while (p && !node[p].ch[c]) {
    node[p].ch[c] = np;
    p = node[p].par;
  }
  if (!p)
    node[np].par = 1;
  else {
    int q = node[p].ch[c];
    if (node[q].len == node[p].len + 1)
      node[np].par = q;
    else {
      int nq = ++id;
      node[nq].len = node[p].len + 1;
      memcpy(node[nq].ch, node[q].ch, sizeof(node[q].ch));
      node[nq].par = node[q].par;
      node[q].par = node[np].par = nq;
      while (p && node[p].ch[c] == q) {
        node[p].ch[c] = nq;
        p = node[p].par;
      }
    }
  }
  lst = np;
}
void dfs(int u, int d) {
  if (d > n) return;
  for (int j = 0; j < 26; j++)
    if (node[u].ch[j]) {
      s[d] = char(j + 'a');
      dfs(node[u].ch[j], d + 1);
      return;
    }
}
int main() {
  scanf("%d%d%s", &n, &k, s + 1);
  k = min(k, 20);
  reverse(s + 1, s + n + 1);
  while (k--) {
    reverse(s + 1, s + n + 1);
    id = lst = 1;
    memset(node, 0, sizeof(node));
    for (int i = 1; i <= n; i++) extend(s[i] - 'a');
    for (int i = n; i >= 1; i--) extend(s[i] - 'a');
    dfs(1, 1);
  }
  puts(s + 1);
  return 0;
}
