#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int n, k, st = 0, ed;
  cin >> n >> k >> s;
  if (k > 30 || (1 << (k - 1)) >= n) {
    cout << string(n, *min_element(s.begin(), s.end())) << "\n";
    return 0;
  }
  string S = s;
  reverse(S.begin(), S.end());
  string T = s + S;
  for (int i = 1; i < n; i++)
    if (T.substr(i, n) < T.substr(st, n)) st = i;
  for (ed = st; ed - st + 1 < n && T[st] == T[ed]; ed++)
    ;
  for (int i = 1; i <= ((ed - st) << (k - 1)); i++) cout << T[st], n--;
  while (n--) cout << T[ed++];
  cout << "\n";
  return 0;
}
