#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
const int maxn = 2e5 + 100;
const int mod = 1e9 + 7;
int n, k;
string solve(string s, int kk) {
  string b;
  for (int i = n - 1; i >= 0 && s[i] == s[n - 1]; i--) {
    cout << i << endl;
    b += s[i];
  }
  for (int i = 0; i < kk; i++) {
    s = s + b;
    b = b + b;
  }
  assert((int)s.size() >= n);
  s = s.substr((int)s.size() - n, n);
  reverse(s.begin(), s.end());
  return s;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0);
  cin >> n >> k;
  string s;
  cin >> s;
  char mn = 'z';
  for (int i = 0; i < n; i++) mn = min(mn, s[i]);
  if (k > 15) return cout << string(n, mn) << "\n", 0;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == mn) {
      int j = i;
      while (j + 1 < n && s[j + 1] == mn) ++j;
      cnt = max(cnt, j - i + 1);
      i = j;
    }
  }
  int cnt2 = 0;
  while (cnt2 < n && s[n - cnt2 - 1] == mn) cnt2++;
  ll tot = cnt;
  for (int i = 0; i < k - 1; i++) tot *= 2;
  if (tot >= n) return cout << string(n, mn) << "\n", 0;
  tot = cnt2;
  for (int i = 0; i < k; i++) tot *= 2;
  if (tot >= n) return cout << string(n, mn) << "\n", 0;
  string t = s;
  reverse(t.begin(), t.end());
  string st = s + t;
  string ans = min(ans, solve(s, k - 1));
  for (int i = 0; i <= n; i++) {
    string ss = st.substr(i, n);
    ans = min(ans, ss);
    ans = min(ans, solve(ss, k - 1));
    if (k >= 2) {
      reverse(ss.begin(), ss.end());
      ans = min(ans, solve(ss, k - 2));
    }
  }
  cout << ans << "\n";
  return 0;
}
