#include <bits/stdc++.h>
using namespace std;
bool compare(string &&x, string &y, bool reversed) {
  if (reversed) reverse(x.begin(), x.end()), reverse(y.begin(), y.end());
  bool ret = x < y;
  if (reversed) reverse(x.begin(), x.end()), reverse(y.begin(), y.end());
  return ret;
}
int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  for (int i = 0; i < k; i++) {
    string t = s;
    reverse(t.begin(), t.end());
    s += t;
    string best(n, 'z');
    for (int j = 0; j <= n; j++) {
      if (compare(s.substr(j, n), best, i != k - 1)) best = s.substr(j, n);
    }
    if (best == s) {
      cout << best << endl;
      return 0;
    }
    s = best;
  }
  cout << s << endl;
  return 0;
}
