#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
void pre() {}
void solve() {}
int cnt[10009];
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  pre();
  int n;
  cin >> n;
  int k;
  cin >> k;
  string s;
  cin >> s;
  string ans = s;
  string t = s;
  reverse(t.begin(), t.end());
  s = s + t;
  char c = 'z';
  for (auto& i : s) c = min(c, i);
  int gg = 1;
  for (int i = 1; i <= (2 * n); ++i) {
    if (s[i - 1] == c)
      cnt[i] = cnt[i - 1] + 1;
    else
      cnt[i] = 0;
    if (cnt[i] + 2 * n - i >= n) gg = max(gg, cnt[i]);
  }
  gg = min(gg, n);
  if (k > 13 || (1 << (k - 1)) * gg >= n) {
    cout << string(n, c);
    return 0;
  }
  string pre = string((1 << (k - 1)) * gg, c);
  int l = n - (int)(pre).size();
  for (int i = 1; i <= (n); ++i) {
    if (cnt[i] >= gg && cnt[i] + 2 * n - i >= n) {
      ans = min(ans, pre + s.substr(i, l));
    }
  }
  cout << ans;
  return 0;
}
