#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 5;
char c[N], s[N], t[N];
int n, k;
inline bool check(char *c, char *t) {
  for (register int i = 0; i < n; i++)
    if (c[i] > t[i])
      return false;
    else if (c[i] < t[i])
      return true;
  return false;
}
inline bool run() {
  for (register int i = n - 1; ~i; i--)
    if (s[i] != s[n - 1]) return true;
  return false;
}
inline void com(char *c, char *t) {
  if (check(c, t))
    for (register int i = 0; i < n; i++) t[i] = c[i];
}
int main() {
  scanf("%d%d%s", &n, &k, s), k--;
  for (register int i = 0; i < n; i++) s[2 * n - 1 - i] = s[i];
  while (run() && k--) {
    for (register int i = 0; i < n; i++) t[i] = 'z';
    for (register int i = 0; i < n; i++) {
      for (register int j = i, k = n - 1; j < i + n; j++) c[k--] = s[j];
      com(c, t);
    }
    reverse(t, t + n);
    for (register int i = 0; i < n; i++) s[i] = t[i];
    for (register int i = 0; i < n; i++) s[2 * n - 1 - i] = s[i];
  }
  for (register int i = 0; i < n; i++) t[i] = 'z';
  for (register int i = 0; i < n; i++) {
    for (register int j = i, k = 0; j < i + n; j++) c[k++] = s[j];
    com(c, t);
  }
  cout << t << endl;
  return 0;
}
