#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr ll LONGINF = 1050000000000000000;
int main() {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  string ans = "";
  if (k == 1) {
    string t = s;
    reverse(t.begin(), t.end());
    s = s + t;
    string x = s.substr(0, n);
    for (int i = 1; i < n; i++) {
      string y = s.substr(i, n);
      if (x > y) {
        x = y;
      }
    }
    ans = x;
  } else {
    string t = s;
    reverse(t.begin(), t.end());
    s = s + t;
    string x = s.substr(0, n);
    reverse(x.begin(), x.end());
    for (int i = 1; i < n; i++) {
      string y = s.substr(i, n);
      reverse(y.begin(), y.end());
      if (x > y) {
        x = y;
      }
    }
    int tmp = 1;
    for (int i = 1; i < x.size(); i++) {
      if (x[i] == x[i - 1]) {
        tmp++;
      } else {
        break;
      }
    }
    string check = x.substr(tmp, x.size());
    string answer = x.substr(0, tmp);
    int kk = k;
    int m = n;
    int kaisuu = 0;
    while (m) {
      m /= 2;
      kaisuu++;
    }
    while (--kk && kaisuu--) {
      answer = answer + answer;
    }
    answer = answer + check;
    ans = answer.substr(0, n);
  }
  cout << ans << endl;
  return 0;
}
