#include <bits/stdc++.h>
using namespace std;
void read(int &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -f;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  x *= f;
}
void print(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (!x) return;
  print(x / 10), putchar(x % 10 + 48);
}
void write(int x) {
  if (!x)
    putchar('0');
  else
    print(x);
  putchar('\n');
}
const int maxn = 1e6 + 10;
const int inf = 1e9;
const double eps = 1e-8;
const int mod = 1e9 + 7;
int n, k;
char s[maxn];
vector<int> p;
int cmp(int a, int b) {
  for (; a && b; a--, b--)
    if (s[a] > s[b])
      return 0;
    else if (s[a] < s[b])
      return 1;
  return 0;
}
int main() {
  read(n), read(k), scanf("%s", s + 1);
  int t = 1e9;
  for (int i = n + 1; i <= 2 * n; i++)
    s[i] = s[2 * n - i + 1], t = min(t, (int)s[i]);
  int mx = 0, r = 0;
  for (int i = 1; i <= (n << 1) + 1; i++)
    if (s[i] != t && s[i - 1] == t) {
      if (r > mx)
        mx = r, p.clear(), i > n ? p.push_back(i - 1) : void();
      else if (r == mx)
        i > n ? p.push_back(i - 1) : void();
      r = 0;
    } else if (s[i] == t)
      r++;
  t = p[0];
  for (int i = 1; i < p.size(); i++)
    if (cmp(i, t)) t = i;
  k--;
  if (k > 18)
    for (int i = 1; i <= n; i++) putchar(s[t]);
  else {
    for (int i = 1; i <= min(n, mx * (1 << k)); i++) putchar(s[t]);
    for (int i = 1; i <= max(0, n - mx * (1 << k)); i++)
      putchar(s[t - mx + 1 - i]);
  }
  puts("");
  return 0;
}
