#include <bits/stdc++.h>
using namespace std;
int N, K;
string S;
int from[5050][2];
int to[5050][2];
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  cin >> N >> K >> S;
  if (K == 1) {
    string T = S;
    string ret = S;
    reverse((T.begin()), (T.end()));
    S += T;
    for (i = 0; i < (N); i++) ret = min(ret, S.substr(i, N));
    cout << ret << endl;
    return;
  }
  char ret = 'z';
  for (auto& c : S) ret = min(ret, c);
  int num = 0, ma = 0;
  for (auto& c : S) {
    if (c == ret)
      num++;
    else
      num = 0;
    ma = max(ma, num);
  }
  if (K >= 13 || (num << (K - 1)) >= N) {
    for (i = 0; i < (N); i++) cout << ret;
    cout << endl;
    return;
  }
  string R = "{";
  for (i = 0; i < (N); i++) {
    if (S[i] != ret || i + ma > N) continue;
    for (j = 0; j < (ma); j++)
      if (S[i + j] != ret) break;
    if (j != ma) continue;
    string T = S.substr(i, ma);
    if (i + ma == N) {
      for (j = 0; j < (K); j++) T = T + T;
      for (j = 0; j < (N - (ma << K)); j++) {
        x = i - 1 - j >= 0;
        if (x >= 0)
          T += S[x];
        else
          T += S[-x + 1];
      }
    } else {
      for (j = 0; j < (K - 1); j++) T = T + T;
      x = i + ma;
      for (j = 0; j < (N - (ma << (K - 1))); j++) {
        if (x < N)
          T += S[x];
        else
          T += S[2 * N - 1 - x];
        x++;
      }
    }
    R = min(R, T);
  }
  cout << R << endl;
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);
  for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);
  cout.tie(0);
  solve();
  return 0;
}
