#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
int n, k;
char s[N];
int main() {
  cin >> n >> k >> s + 1;
  char a = *min_element(s + 1, s + 1 + n);
  int L = 0;
  for (int i = 1, j; i <= n;)
    if (s[i] == a) {
      for (j = i; j <= n && s[j] == a; ++j)
        ;
      L = max(L, j - i);
      i = j;
    } else
      ++i;
  if (L << min(15, k - 1) >= n) {
    for (int i = 1; i <= n; ++i) cout << a;
    cout << endl;
    return 0;
  }
  string ans;
  for (int i = 1, j; i <= n;)
    if (s[i] == a) {
      for (j = i; j <= n && s[j] == a; ++j)
        ;
      if (j - i == L) {
        string now;
        for (int x = 1; x <= L << k - 1; ++x) now += a;
        for (int x = j; now.size() < n; ++x)
          now += s[x <= n ? x : 2 * n + 1 - x];
        if (ans.empty() || now < ans) ans = now;
      }
      i = j;
    } else
      ++i;
  if (s[n] == a) {
    string now;
    int i = n;
    while (i > 1 && s[i - 1] == a) --i;
    i = n - i + 1;
    for (int x = 1; x <= i << k; ++x) now += a;
    for (int x = n - 1; now.size() < n; --x) now += s[x];
    if (ans.empty() || now < ans) ans = now;
  }
  cout << ans << '\n';
}
