#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  string t = s;
  reverse(t.begin(), t.end());
  s += t;
  reverse(s.begin(), s.end());
  for (int i = 0; i < min(n, k) - 1; i++) {
    map<string, int> m;
    for (int j = 0; j < n; j++) {
      string tmp = s.substr(j, n);
      m[tmp]++;
    }
    for (auto p : m) {
      s = p.first;
      break;
    }
    t = s;
    reverse(s.begin(), s.end());
    s += t;
  }
  reverse(s.begin(), s.end());
  map<string, int> m;
  for (int j = 0; j < n; j++) {
    string tmp = s.substr(j, n);
    m[tmp]++;
  }
  for (auto p : m) {
    s = p.first;
    break;
  }
  cout << s << endl;
  return 0;
}
