#include <bits/stdc++.h>
using std::max;
using std::min;
const int inf = 0x3f3f3f3f, Inf = 0x7fffffff;
const long long INF = 0x3f3f3f3f3f3f3f3f;
__inline__ __attribute__((always_inline)) unsigned int rnd() {
  static unsigned int seed = 416;
  return seed ^= seed >> 5, seed ^= seed << 17, seed ^= seed >> 13;
}
template <typename _Tp>
_Tp gcd(const _Tp &a, const _Tp &b) {
  return (!b) ? a : gcd(b, a % b);
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) _Tp abs(const _Tp &a) {
  return a >= 0 ? a : -a;
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) void chmax(_Tp &a, const _Tp &b) {
  (a < b) && (a = b);
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) void chmin(_Tp &a, const _Tp &b) {
  (b < a) && (a = b);
}
template <typename _Tp>
__inline__ __attribute__((always_inline)) void read(_Tp &x) {
  char ch(getchar());
  bool f(false);
  while (!isdigit(ch)) f |= ch == 45, ch = getchar();
  x = ch & 15, ch = getchar();
  while (isdigit(ch)) x = (((x << 2) + x) << 1) + (ch & 15), ch = getchar();
  f && (x = -x);
}
template <typename _Tp, typename... Args>
__inline__ __attribute__((always_inline)) void read(_Tp &t, Args &...args) {
  read(t);
  read(args...);
}
template <typename _Tp, typename... Args>
__inline__ __attribute__((always_inline)) _Tp min(const _Tp &a, const _Tp &b,
                                                  const Args &...args) {
  return a < b ? min(a, args...) : min(b, args...);
}
template <typename _Tp, typename... Args>
__inline__ __attribute__((always_inline)) _Tp max(const _Tp &a, const _Tp &b,
                                                  const Args &...args) {
  return a < b ? max(b, args...) : max(a, args...);
}
__inline__ __attribute__((always_inline)) int read_str(char *s) {
  char ch(getchar());
  while (ch == ' ' || ch == '\r' || ch == '\n') ch = getchar();
  char *tar = s;
  *tar = ch, ch = getchar();
  while (ch != ' ' && ch != '\r' && ch != '\n' && ch != EOF)
    *(++tar) = ch, ch = getchar();
  return tar - s + 1;
}
int main() {
  int n, k;
  read(n, k);
  std::string s, t;
  std::cin >> s;
  char minn = 127;
  for (int i = 0; i < n; ++i) chmin(minn, s[i]);
  if (k >= 14) {
    for (int i = 1; i <= n; ++i) printf("%c%c", minn, " \n"[i == n]);
    return 0;
  }
  --k;
  int qwq = 1;
  for (int i = 0; i < k; ++i) qwq <<= 1;
  t.resize(n + n);
  for (int i = 0; i < n; ++i) t[i] = s[i], t[i + n] = s[n - i - 1];
  std::string ans = s;
  for (int i = n - 1; i < n + n; ++i) {
    int pos = i;
    while (pos >= 0 && t[pos] == t[i]) --pos;
    int cnt = i - pos;
    std::string cur;
    cur.resize(n);
    if (qwq * cnt >= n)
      for (int j = 0; j < n; ++j) cur[j] = t[i];
    else {
      for (int j = 0; j < qwq * cnt; ++j) cur[j] = t[i];
      for (int j = qwq * cnt; j < n; ++j) cur[j] = t[pos--];
    }
    if (cur < ans) ans = cur;
  }
  printf("%s\n", ans.c_str());
  return 0;
}
