#include <bits/stdc++.h>
using namespace std;
int n, k;
char s[10010], st[10010];
int id[10010], x[10010], y[10010], c[10010];
void build(char *s) {
  int n = strlen(s) + 1, m = 256;
  for (int i = 0; i < m; i++) c[i] = 0;
  for (int i = 0; i < n; i++) c[x[i] = s[i]]++;
  for (int i = 1; i < m; i++) c[i] += c[i - 1];
  for (int i = n - 1; i >= 0; i--) id[--c[x[i]]] = i;
  for (int j = 1, p = 1; p < n; j <<= 1, m = p) {
    p = 0;
    for (int i = n - j; i < n; i++) y[p++] = i;
    for (int i = 0; i < n; i++)
      if (id[i] >= j) y[p++] = id[i] - j;
    for (int i = 0; i < m; i++) c[i] = 0;
    for (int i = 0; i < n; i++) c[x[i]]++;
    for (int i = 1; i < m; i++) c[i] += c[i - 1];
    for (int i = n - 1; i >= 0; i--) id[--c[x[y[i]]]] = y[i];
    swap(x, y);
    x[id[0]] = 0, p = 1;
    for (int i = 1; i < n; i++) {
      x[id[i]] = (y[id[i]] == y[id[i - 1]] && y[id[i] + j] == y[id[i - 1] + j])
                     ? p - 1
                     : p++;
    }
  }
}
int main() {
  scanf("%d %d %s", &n, &k, s);
  strcpy(st, s);
  reverse(st, st + strlen(st));
  strcat(s, st);
  k--;
  build(s);
  int t = 1;
  for (; id[t] >= n; t++)
    ;
  t = id[t];
  int l = 1;
  while (l < n && s[t + l] == s[t]) l++;
  vector<char> vec;
  for (int i = l; i < n; i++) vec.push_back(s[t + i]);
  while (k--) {
    l <<= 1;
    if (l >= n) break;
  }
  for (int i = 0; i < l; i++) putchar(s[t]);
  for (int i = l; i < n; i++) putchar(vec[i - l]);
  puts("");
}
