#include <bits/stdc++.h>
using namespace std;
struct SuffixArray {
  vector<int> lcp;
  vector<vector<pair<int, int> > > rmq;
  int n, h;
  vector<int> sa, invsa;
  bool cmp(int a, int b) { return invsa[a + h] < invsa[b + h]; }
  void ternary_sort(int a, int b) {
    if (a == b) return;
    int pivot = sa[a + rand() % (b - a)];
    int left = a, right = b;
    for (int i = a; i < b; i++)
      if (cmp(sa[i], pivot)) swap(sa[i], sa[left++]);
    for (int i = b - 1; i >= left; i--)
      if (cmp(pivot, sa[i])) swap(sa[i], sa[--right]);
    ternary_sort(a, left);
    for (int i = left; i < right; i++) invsa[sa[i]] = right - 1;
    if (right - left == 1) sa[left] = -1;
    ternary_sort(right, b);
  }
  SuffixArray() {}
  SuffixArray(vector<int> v) : n(v.size()), sa(n) {
    v.push_back(INT_MIN);
    invsa = v;
    iota(sa.begin(), sa.end(), 0);
    h = 0;
    ternary_sort(0, n);
    for (h = 1; h <= n; h *= 2)
      for (int j = 0, i = j; i != n; i = j)
        if (sa[i] < 0) {
          while (j < n && sa[j] < 0) j += -sa[j];
          sa[i] = -(j - i);
        } else {
          j = invsa[sa[i]] + 1;
          ternary_sort(i, j);
        }
    for (int i = 0; i < n; i++) sa[invsa[i]] = i;
    return;
    lcp.resize(n);
    int res = 0;
    for (int i = 0; i < n; i++) {
      if (invsa[i] > 0)
        while (v[i + res] == v[sa[invsa[i] - 1] + res]) res++;
      lcp[invsa[i]] = res;
      res = max(res - 1, 0);
    }
    int logn = 0;
    while ((1 << (logn + 1)) <= n) logn++;
    rmq.resize(logn + 1, vector<pair<int, int> >(n));
    for (int i = 0; i < n; i++) rmq[0][i] = make_pair(lcp[i], i);
    for (int l = 1; l <= logn; l++)
      for (int i = 0; i + (1 << l) <= n; i++)
        rmq[l][i] = min(rmq[l - 1][i], rmq[l - 1][i + (1 << (l - 1))]);
  }
  pair<int, int> rmq_query(int a, int b) {
    int size = b - a + 1;
    int l = __builtin_clz(1) - __builtin_clz(size);
    return min(rmq[l][a], rmq[l][b - (1 << l) + 1]);
  }
  int get_lcp(int a, int b) {
    if (a == b) return n - a;
    int ia = invsa[a], ib = invsa[b];
    return rmq_query(min(ia, ib) + 1, max(ia, ib)).first;
  }
};
int main() {
  srand(time(NULL));
  int n, k;
  cin >> n >> k;
  string s, t;
  cin >> s;
  t = s;
  reverse(t.begin(), t.end());
  s += t;
  struct opt {
    int start;
    int size;
    char c;
  };
  vector<opt> opts;
  string ans(n, 'z');
  if (k == 1) {
    for (int i = 0; i <= n; i++) {
      string now = s.substr(i, n);
      if (now < ans) ans = now;
    }
    cout << ans << endl;
    return 0;
  }
  for (int i = 0; i <= n; i++) {
    opt now = {i, 0, s[i + n - 1]};
    for (int j = i + n - 1; j >= i && s[j] == now.c; j--, now.size++)
      ;
    int first_off = i + n - 1 - now.size;
    for (int j = 0; j < k - 2 && now.size < n; j++) {
      now.size *= 2;
    }
    string here;
    int len_here = 0;
    for (int j = 0; len_here < n && j < now.size; j++) {
      here.push_back(now.c);
      len_here++;
    }
    for (int j = first_off; len_here < n && j >= i; j--) {
      here.push_back(s[j]);
      len_here++;
    }
    reverse(here.begin(), here.end());
    string up = here;
    reverse(up.begin(), up.end());
    here += up;
    vector<int> vhere;
    for (auto c : here) vhere.push_back(c);
    SuffixArray s(vhere);
    for (int vi : s.sa) {
      if (vi <= n) {
        string now = here.substr(vi, n);
        if (now < ans) ans = now;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
