#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, k; cin >> n >> k;
  string s; cin >> s;
  char c = *min_element(begin(s), end(s));
  if (k >= __lg(2 * n - 1)) {
    cout << string(n, c) << '\n';
  } else {
    string res = s;
    for (int i = 0; i <= n; ++i) {
      string crr = s + s;
      reverse(begin(crr) + n, end(crr));
      crr = crr.substr(i, n);
      for (int t = 1; t < k; ++t) {
        crr += crr;
        reverse(begin(crr) + n, end(crr));
        for (int j = 0; j <= n; ++j) {
          res = min(res, crr.substr(j, n));
        }
        int j = n;
        while (crr[j] == crr[n]) ++j;
        crr = crr.substr(j - n, n);
      }
      res = min(res, crr);
    }
    cout << res << '\n';
  }
}