#include <bits/stdc++.h>
using namespace std;
int N, K;
string s, rev, tmp, str;
int main() {
  cin >> N >> K >> s;
  rev = s, reverse(rev.begin(), rev.end());
  tmp = s + rev, reverse(tmp.begin(), tmp.end());
  str = tmp.substr(0, N);
  for (register int i = 1; i < N; ++i) {
    rev = tmp.substr(i, N);
    if (rev < str) str = rev;
  }
  reverse(str.begin(), str.end());
  for (register int i = 1, j; i < K; ++i) {
    for (j = N - 2; ~j; --j)
      if (str[j] != str[N - 1]) break;
    str = str + str.substr(j + 1, N);
    j = str.length();
    str = str.substr(j - N, N);
  }
  reverse(str.begin(), str.end());
  cout << str;
  return 0;
}
