#include <bits/stdc++.h>
using namespace std;
string s;
int n, m;
int main() {
  cin >> n >> m;
  cin >> s;
  while (m--) {
    string t = s;
    reverse(t.begin(), t.end());
    string ss = s + t;
    string ff = "\xff";
    for (int i = 0; i + n <= ss.size(); i++) {
      ff = min(ff, ss.substr(i, n));
    }
    if (!m) {
      cout << ff << endl;
      return 0;
    }
    reverse(ff.begin(), ff.end());
    bool xx = 1;
    for (int i = 1; i < n; i++) {
      if (ff[xx] != ff[xx - 1]) {
        xx = 0;
        break;
      }
    }
    if (xx) {
      cout << ff << endl;
      return 0;
    }
    s = ff;
  }
  cout << s << endl;
  return 0;
}
