#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  string t = s;
  reverse(t.begin(), t.end());
  s += t;
  int l = 0;
  for (int i = 1; i <= n; i++) {
    if (s.substr(i, n) < s.substr(l, n)) l = i;
  }
  int c, r = 0;
  for (c = 1; c < n; c++) {
    if (s[l + c] != s[l]) {
      r = l + c;
      break;
    }
  }
  for (int i = 0; i < k - 1; i++) {
    c <<= 1;
    if (c >= n) {
      c = n;
      break;
    }
  }
  for (int i = 0; i < c; i++) cout << s[l];
  for (int i = 0; i < n - c; i++) cout << s[r + i];
  cout << endl;
}
