#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  char m = 'z';
  for (int i = 0; i < s.size(); i++) m = min(m, s[i]);
  if (k >= 15) {
    for (int i = 0; i < n; i++) cout << m;
    cout << endl;
    return 0;
  }
  if (k == 1) {
    string t1 = s;
    reverse(t1.begin(), t1.end());
    s = (s + t1);
    for (int i = 0; i < n; i++) {
      t1 = min(t1, s.substr(i, n));
    }
    cout << t1 << endl;
    return 0;
  }
  int st[5010], en[5010];
  int ind = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == m) {
      if (i == 0)
        st[ind] = i;
      else if (s[i - 1] != m)
        st[ind] = i;
      if (i == n - 1) {
        en[ind] = i + 1;
        ind++;
      } else if (s[i + 1] != m) {
        en[ind] = i + 1;
        ind++;
      }
    }
  }
  int mx = 0;
  for (int i = 0; i < ind; i++) mx = max(mx, en[i] - st[i]);
  if ((n + mx - 1) / mx < (int)(1 << (k - 1))) {
    for (int i = 0; i < n; i++) cout << m;
    cout << endl;
    return 0;
  }
  int mlt = (int)(1 << (k - 1));
  string ans = s;
  for (int i = 0; i < ind; i++) {
    if (en[i] < n) {
      string t0 = s;
      reverse(t0.begin(), t0.end());
      t0 = s + t0;
      string t1 = t0.substr(n - st[i], n);
      string t2 = t1;
      reverse(t2.begin(), t2.end());
      string t3 = t2.substr(0, en[i] - st[i]);
      t2 = t2.substr(en[i] - st[i], n - (en[i] - st[i]));
      for (int j = 0; j < k - 1; j++) t3 = t3 + t3;
      t2 = t3 + t2;
      t2 = t2.substr(0, n);
      ans = min(s, t2);
    } else {
      string t0 = s;
      reverse(t0.begin(), t0.end());
      t0 = s + t0;
      string t1 = t0.substr(n - st[i], n);
      string t2 = t1;
      reverse(t2.begin(), t2.end());
      string t3 = t2.substr(0, en[i] - st[i]);
      t2 = t2.substr(en[i] - st[i], n - (en[i] - st[i]));
      for (int j = 0; j < k; j++) t3 = t3 + t3;
      t2 = t3 + t2;
      t2 = t2.substr(0, n);
      ans = min(s, t2);
    }
  }
  cout << ans << endl;
  return 0;
}
