#include <bits/stdc++.h>
using namespace std;
int n, k, i, j, ok;
char s[10005], a[10005], sol[5005], minim;
void solve() {
  int i, ii, st, ok;
  for (ii = 1; ii < k; ii++) {
    for (i = 1; i <= n; i++) {
      a[2 * n - i + 1] = a[i];
    }
    if (ii != k - 1) {
      st = (1 << (ii - 1)) + 1;
    } else {
      st = n - (1 << (ii - 1)) + 1;
    }
    for (i = st; i < st + n; i++) {
      a[i - st + 1] = a[i];
    }
  }
  ok = 0;
  for (i = 1; i <= n; i++) {
    if (a[i] != sol[i]) {
      if (a[i] < sol[i]) {
        ok = 1;
      }
      break;
    }
  }
  if (ok == 1) {
    for (i = 1; i <= n; i++) {
      sol[i] = a[i];
    }
  }
}
int main() {
  cin >> n >> k;
  cin >> s + 1;
  minim = 'z';
  for (i = 1; i <= n; i++) {
    minim = min(minim, s[i]);
  }
  if (k > 20 || (1 << (k - 1)) >= n) {
    for (i = 1; i <= n; i++) {
      cout << minim;
    }
    return 0;
  }
  for (i = 1; i <= n; i++) {
    sol[i] = 'z';
    s[n + n - i + 1] = s[i];
  }
  if (k == 1) {
    for (i = n; i <= 2 * n; i++) {
      for (j = i - n + 1; j <= i; j++) {
        a[j - i + n] = s[j];
      }
      ok = 0;
      for (j = 1; j <= n; j++) {
        if (a[j] != sol[j]) {
          if (a[j] < sol[j]) {
            ok = 1;
          }
          break;
        }
      }
      if (ok == 1) {
        for (j = 1; j <= n; j++) {
          sol[j] = a[j];
        }
      }
    }
    cout << sol + 1;
    return 0;
  }
  for (i = n; i <= 2 * n; i++) {
    if (s[i] == minim) {
      for (j = i - n + 1; j <= i; j++) {
        a[j - i + n] = s[j];
      }
      solve();
    }
  }
  cout << sol + 1;
}
