#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) { return (!y ? x : gcd(y, x % y)); }
const int maxn = 5000 * 10;
int num[maxn];
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  char c = 'z';
  for (int i = 0; i < n; i++) c = min(c, s[i]);
  string org = s;
  string ans;
  for (int i = 0; i < n; i++) ans += 'z';
  if (k >= 14) {
    ans = "";
    for (int i = 0; i < n; i++) ans += c;
    cout << ans << '\n';
    return 0;
  }
  int ted = 0;
  int mx = -1;
  for (int i = 0; i < n; i++) {
    if (s[i] == c)
      ted++;
    else
      ted = 0;
    if (i >= n - 1) mx = max(mx, ted);
    num[i] = ted;
  }
  for (int en = n; en <= 2 * n; en++) {
    s = org;
    string rev = s;
    reverse(rev.begin(), rev.end());
    string st = s + rev;
    s = st.substr(en - n, n);
    ans = min(ans, s);
    if (num[en - 1] != ted) continue;
    for (int it = 1; it < k; it++) {
      int cnt = 0;
      rev = s;
      reverse(rev.begin(), rev.end());
      st = s + rev;
      int mx = -1, who = -1;
      if (it == k - 1) {
        for (int i = 0; i <= n; i++) ans = min(ans, st.substr(i, n));
      } else {
        for (int i = 0; i < 2 * n; i++) {
          if (st[i] == c)
            cnt++;
          else
            cnt = 0;
          if (i >= n - 1 && cnt > mx) {
            mx = cnt;
            who = i + 1;
          }
        }
        s = st.substr(who - n, n);
      }
    }
    ans = min(ans, s);
  }
  cout << ans << '\n';
}
