#include <bits/stdc++.h>
using namespace std;

int n, k;
string s, t;

string solve();

int main() {
  cin >> n >> k >> s;
  t = s;
  reverse(t.begin(), t.end());
  t = s + t;
  cout << solve() << endl;
  return 0;
}

string solve() {
  string res = s;
  if (k == 1) {
    for (int i = 0; i <= n; ++i) res = min(res, t.substr(i, n));
    return res;
  }
  for (int i = 0; i < n; ++i) {
    int id = i + n, cnt = 0;
    while (id > i && t[i + n] == t[id]) --id, ++cnt;
    for (int j = 1; j < k && cnt < n; ++j) cnt = min(n, cnt * 2);
    string now(cnt, t[i + n]);
    while (now.size() < n) now += t[id--];
    res = min(res, now);
  }
  return res;
}