#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1.01e9;
string solve(int n, int k, string s) {
  if (k >= 40) return string(n, *min_element(s.begin(), s.end()));
  auto get_nt = [&](const string &t) {
    string nt = "";
    int z = n - 1;
    while (z > 0 && t[z - 1] == t[z]) z--;
    for (int j = z; j < n; j++) nt += t[j];
    for (int j = n - 1; (int)nt.length() < n; j--) nt += t[j];
    return nt;
  };
  string ans(n, 'z');
  for (int i = 0; i < n; i++) {
    string t = s.substr(i);
    for (int j = n - 1; j >= 0; j--)
      if ((int)t.length() < n) t += s[j];
    for (int it = 1; it < k - 1; it++) {
      auto nt = get_nt(t);
      reverse(nt.begin(), nt.end());
      t = nt;
    }
    if (k > 1) {
      t = get_nt(t);
    }
    ans = min(ans, t);
  }
  return ans;
}
int main() {
  int n, k;
  string s;
  while (cin >> n >> k >> s) {
    cout << solve(n, k, s) << endl;
  }
}
