#include <bits/stdc++.h>
using namespace std;
const int CUT = 14;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  char mn = 'z';
  for (int i = 0; i < n; i++) mn = min(mn, s[i]);
  vector<int> loc;
  vector<pair<pair<int, int>, char>> blocks;
  string t = "";
  for (int i = 0; i < n; i++) t += s[i];
  for (int i = n - 1; i >= 0; i--) t += s[i];
  int it1 = 0, it2 = 0;
  while (it1 != 2 * n) {
    while (it2 != 2 * n - 1 && t[it1] == t[it2 + 1]) it2++;
    blocks.emplace_back(make_pair(it1, it2), t[it1]);
    it1 = ++it2;
  }
  int b_size = 1e9;
  for (auto block : blocks) {
    if (block.second == mn) {
      b_size = min(b_size, block.first.second - block.first.first + 1);
    }
  }
  for (auto block : blocks) {
    if (block.second == mn &&
        block.first.second - block.first.first + 1 == b_size &&
        block.first.second >= n - 1) {
      loc.push_back(block.first.second);
    }
  }
  if (k >= CUT) {
    for (int i = 0; i < n; i++) cout << (char)(mn + 'a');
    cout << '\n';
  } else if (k == 1) {
    string ans = s;
    for (int i = 0; i < n; i++) {
      string check = "";
      for (int j = 0; j < n; j++) {
        check += t[i + j];
      }
      ans = min(ans, check);
    }
    cout << ans << '\n';
  } else {
    string ans = "";
    for (int i = 0; i < n; i++) ans += 'z';
    for (int pos : loc) {
      string check = "";
      for (int i = pos; i >= pos - n + 1; i--) check += t[i];
      reverse(check.begin(), check.end());
      for (int i = 0; i < k - 2; i++) {
        for (int i = n - 1; i >= 0; i--) check += check[i];
        int last = n - 1;
        for (int j = n - 1; j >= 0; j--) {
          if (check[j] == mn)
            last = j;
          else
            break;
        }
        string nxt = "";
        for (int j = n - last; j <= n - last + n - 1; j++) {
          nxt += check[j];
        }
        swap(check, nxt);
      }
      int last = n - 1;
      for (int j = n - 1; j >= 0; j--) {
        if (check[j] == mn)
          last = j;
        else
          break;
      }
      for (int j = n - 1; j >= 0; j--) check += check[j];
      string res = "";
      for (int j = last; j <= last + n - 1; j++) {
        res += check[j];
      }
      ans = min(ans, res);
    }
    cout << ans << '\n';
  }
  return 0;
}
