#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  lint n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  char m = 'z';
  for (int i = 0; i < n; ++i) {
    m = min(m, s[i]);
  }
  vector<int> cnt(n, 0);
  int mx = 0;
  for (int i = n - 1; i >= 0; --i) {
    if (i != n - 1) cnt[i] += cnt[i + 1];
    if (s[i] == m)
      cnt[i]++;
    else
      cnt[i] = 0;
    mx = max(cnt[i], mx);
  }
  mx = max(mx, cnt[n - 1] * 2);
  lint mm = mx;
  for (int i = 1; i < k - 1; ++i) {
    if (mm >= n) {
      cout << string(n, m) << "\n";
      return 0;
    }
    mm *= 2;
  }
  string ret(n, 'z');
  for (int i = 0; i < n - 1; ++i) {
    if (mx == cnt[i]) {
      string tt = s;
      reverse(tt.begin(), tt.end());
      string temp = s + tt;
      string ss = temp.substr(2 * n - i - n, n);
      int len = mx;
      for (int j = 1; j < k - 1; ++j) {
        tt = ss;
        reverse(tt.begin(), tt.end());
        temp = ss + tt;
        len *= 2;
        ss = temp.substr(n - 1 + len - n, n);
      }
      tt = ss;
      reverse(tt.begin(), tt.end());
      temp = ss + tt;
      ss = temp.substr(n - len, n);
      ret = min(ret, ss);
    }
  }
  if (mx == cnt[n - 1] * 2) {
    string ss = s;
    string tt;
    string temp;
    int len = mx / 2;
    for (int j = 0; j < k - 1; ++j) {
      tt = ss;
      reverse(tt.begin(), tt.end());
      temp = ss + tt;
      ss = temp.substr(n - 1 + len - n, n);
      len *= 2;
    }
    tt = ss;
    reverse(tt.begin(), tt.end());
    temp = ss + tt;
    ss = temp.substr(n - len, n);
    ret = min(ret, ss);
  }
  cout << ret << "\n";
  return 0;
}
