#include <bits/stdc++.h>
inline long long read() {
  long long x = 0;
  char c = getchar(), f = 1;
  for (; c < '0' || '9' < c; c = getchar())
    if (c == '-') f = -1;
  for (; '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
inline void write(long long x) {
  static char buf[20];
  int len = 0;
  if (x < 0) putchar('-'), x = -x;
  for (; x; x /= 10) buf[len++] = x % 10 + '0';
  if (!len)
    putchar('0');
  else
    while (len) putchar(buf[--len]);
}
inline void writesp(long long x) {
  write(x);
  putchar(' ');
}
inline void writeln(long long x) {
  write(x);
  putchar('\n');
}
char s[2 * 5010], t[2 * 5010];
int n, k;
int main() {
  n = read();
  k = read();
  scanf("%s", s);
  char mn = 'z';
  for (int i = 0; i < n; i++) mn = std::min(mn, s[i]);
  for (int i = 0; i < n; i++) t[i] = t[2 * n - i - 1] = s[i];
  if (k == 1) {
    int pos = 0;
    for (int i = 1; i < n; i++) {
      int x = i, y = pos;
      while (x < n && y < n && t[x] == t[y]) ++x, ++y;
      if (t[x] < t[y]) pos = i;
    }
    for (int i = pos; i < pos + n; i++) putchar(t[i]);
    putchar('\n');
    return 0;
  }
  int len = 0, last = -1;
  for (int i = 0; i < 2 * n; i++)
    if (t[i] == mn)
      len = std::max(len, i - last);
    else
      last = i;
  int pos = -1;
  for (int i = n - 1; i < 2 * n; i++) {
    int x = i, y = pos;
    while (~x && ~y && t[x] == t[y]) --x, --y;
    if (y == -1 || t[x] < t[y]) pos = i;
  }
  for (int i = 0; i < n; i++) s[i] = t[pos - n + i + 1];
  for (int j = 2; j <= k && len < n; j++) {
    for (int i = 0; i < n; i++) t[i] = t[2 * n - i - 1] = s[i];
    if (j == k) {
      for (int i = 0; i < n; i++) s[i] = t[i + n - len];
    } else {
      for (int i = 0; i < n; i++) s[i] = t[i + len];
    }
    len <<= 1;
  }
  printf("%s\n", s);
  return 0;
}
