#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pll = pair<ll, ll>;
const ll INF = 1e18;
const ll mod = 1e9 + 7;
const double pie = acos(-1);
vll dx4 = {-1, 0, 1, 0};
vll dy4 = {0, -1, 0, 1};
vll dx8 = {-1, 0, 1, 1, 1, 0, -1, -1};
vll dy8 = {-1, 1, -1, 0, 1, 1, 1, 0};
void fix_cout() { cout << fixed << setprecision(20); }
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
void chmax(ll &a, ll b) {
  if (a < b) a = b;
}
void chmin(ll &a, ll b) {
  if (a > b) a = b;
}
int main() {
  ll n, k;
  cin >> n >> k;
  string s, t;
  cin >> s;
  ll cnt = 0;
  for (int i = 1; i < k; i++) {
    bool ok = true;
    for (int j = 0; j < n; j++) ok &= (s.at(0) == s.at(j));
    if (ok) break;
    if (i == 1) {
      string tmp = "";
      tmp += (char)('z' + 1);
      for (int j = 0; j < n; j++) {
        t = "";
        for (int l = 0; l < n; l++)
          t += s.at(min((ll)j + l, 2 * n - 1 - j - l));
        reverse(t.begin(), t.end());
        tmp = min(tmp, t);
      }
      s = tmp;
      for (int j = 0; j < n; j++) {
        if (s.at(j) != s.at(0)) break;
        cnt++;
      }
      reverse(s.begin(), s.end());
    } else {
      t = "";
      for (int j = 0; j < n; j++) t += s.at(min(n - cnt + j, n - 1 + cnt - j));
      reverse(t.begin(), t.end());
      s = t;
      cnt = min(cnt * 2, n);
    }
  }
  string tmp = "";
  tmp += (char)('z' + 1);
  for (int i = 0; i < n; i++) {
    t = "";
    for (int j = 0; j < n; j++) t += s.at(min((ll)i + j, 2 * n - 1 - i - j));
    tmp = min(tmp, t);
  }
  s = tmp;
  cout << s << endl;
}
