/**
 *    author:  tourist
 *    created: 17.08.2019 15:17:53       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  k = min(k, 15);
  string s;
  cin >> s;
  string u = s + string(s.rbegin(), s.rend());
  string ans = s;
  for (int i = 0; i <= n; i++) {
    string t = u.substr(i, n);
    string w;
    if (k == 1) {
      w = t;
    } else {
      int cnt = 0;
      for (int j = n - 1; j >= 0; j--) {
        if (t[j] == t[n - 1]) {
          ++cnt;
        } else {
          break;
        }
      }
      int in_w = min(cnt << (k - 1), n);
      w = string(in_w, t[n - 1]);
      int rm = n - (int) w.size();
      string sub = t.substr(n - cnt - rm, rm);
      w += string(sub.rbegin(), sub.rend());
    }
    ans = min(ans, w);
  }
  cout << ans << '\n';
  return 0;
}
