#include <bits/stdc++.h>
using namespace std;
namespace mine {
long long qread() {
  long long ans = 0, f = 1;
  char c = getchar();
  while (c < '0' or c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while ('0' <= c and c <= '9') ans = ans * 10 + c - '0', c = getchar();
  return ans * f;
}
void write(long long num) {
  if (num < 0) putchar('-'), num = -num;
  if (num >= 10) write(num / 10);
  putchar('0' + num % 10);
}
void write1(long long num) {
  write(num);
  putchar(' ');
}
void write2(long long num) {
  write(num);
  putchar('\n');
}
void chmax(int &x, const long long y) { x = (x > y ? x : y); }
void chmin(int &x, const long long y) { x = (x < y ? x : y); }
long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : 0; }
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;
inline int mm(const int x) { return x >= MOD ? x - MOD : x; }
inline long long qpower(long long x, long long e) {
  long long ans = 1;
  while (e) {
    if (e & 1) ans = ans * x % MOD;
    x = x * x % MOD;
    e >>= 1;
  }
  return ans;
}
inline int invm(int x) { return qpower(x, MOD - 2); }
const int N = 1e6 + 10;
char str[N];
int n;
int getmi(int a, int b) {
  int ta = a, tb = b;
  while (str[a] == str[b]) a++, b++;
  return str[a] < str[b] ? ta : tb;
}
vector<char> ans, ans2;
void main() {
  int n = qread(), k = qread() - 1;
  scanf("%s", str);
  for (int i = n; i < n + n; i++) str[i] = str[i - n];
  reverse(str + n, str + n + n);
  int mi = 0;
  for (int i = 1; i <= n; i++) mi = getmi(mi, i);
  int cnt = 0;
  while (cnt < n and str[mi] == str[mi + cnt]) cnt++;
  mi = (n + n - 1 - mi) - n + 1;
  for (int i = mi; i < mi + n; i++) ans.push_back(str[i]);
  while (k--) {
    ans2.clear();
    if (cnt * 2 >= n) {
      while (n--) ans2.push_back(ans[0]);
      swap(ans, ans2);
      break;
    }
    int st = n - 1 - (n - cnt) + 1, op = 1;
    int pp = n;
    while (pp--) {
      ans2.push_back(ans[st]);
      st += op;
      if (st == n) st--, op = -1;
    }
    swap(ans, ans2);
    cnt *= 2;
  }
  for (int t = ((int)(ans).size()) - 1; t >= 0; t--) putchar(ans[t]);
}
};  // namespace mine
int main() {
  srand(time(0));
  mine::main();
}
