#include <bits/stdc++.h>
using namespace std;
template <int size, int alp>
struct automaton {
  struct node {
    int len, link, next[alp];
    int height;
  };
  node aut[size * 2];
  int vis[size * 2];
  int tam, ult;
  void init() {
    tam = 1;
    ult = aut[0].len = 0;
    aut[0].link = -1;
    memset(vis, 0, sizeof(vis));
    memset(aut[0].next, 0, sizeof(aut[0].next));
  }
  void extend(int c) {
    int cur = tam++, p;
    aut[cur].len = aut[ult].len + 1;
    memset(aut[cur].next, 0, sizeof(aut[cur].next));
    for (p = ult; p != -1 && aut[p].next[c] == 0; p = aut[p].link)
      aut[p].next[c] = cur;
    if (p == -1)
      aut[cur].link = 0;
    else {
      int q = aut[p].next[c];
      if (aut[p].len + 1 == aut[q].len)
        aut[cur].link = q;
      else {
        int clone = tam++;
        aut[clone].len = aut[p].len + 1;
        memcpy(aut[clone].next, aut[q].next, sizeof(int) * alp);
        aut[clone].link = aut[q].link;
        for (; p != -1 && aut[p].next[c] == q; p = aut[p].link)
          aut[p].next[c] = clone;
        aut[q].link = aut[cur].link = clone;
      }
    }
    ult = cur;
  }
  bool search(string v) {
    int pos = 0;
    for (int e = 0; e < v.size(); e++)
      if (aut[pos].next[v[e]] == 0)
        return false;
      else
        pos = aut[pos].next[v[e]];
    return true;
  }
  void dfs(int u) {
    if (vis[u]) return;
    vis[u] = 1;
    aut[u].height = 0;
    for (int j = 0; j < alp; j++)
      if (aut[u].next[j]) {
        dfs(aut[u].next[j]);
        aut[u].height = max(aut[u].height, 1 + aut[aut[u].next[j]].height);
      }
  }
  string of_size(int n) {
    dfs(0);
    string res;
    int cur = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < alp; j++)
        if (aut[cur].next[j] && aut[aut[cur].next[j]].height >= n - i - 1) {
          res.push_back('a' + j);
          cur = aut[cur].next[j];
          break;
        }
    }
    return res;
  }
};
int main() {
  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;
    automaton<10100, 26> aut;
    aut.init();
    for (auto c : here) aut.extend(c - 'a');
    string can = aut.of_size(n);
    if (can < ans) ans = can;
  }
  cout << ans << endl;
  return 0;
}
