#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template <class T, class U>
void init_n(vector<T>& v, size_t n, U x) {
  v = vector<T>(n, x);
}
template <class T>
void init_n(vector<T>& v, size_t n) {
  init_n(v, n, T());
}
template <class T>
void read_n(vector<T>& v, size_t n, size_t o = 0) {
  v = vector<T>(n + o);
  for (size_t i = o; i < n + o; ++i) cin >> v[i];
}
template <class T>
void read_n(T a[], size_t n, size_t o = 0) {
  for (size_t i = o; i < n + o; ++i) cin >> a[i];
}
template <class T>
T gabs(const T& x) {
  return max(x, -x);
}
i64 n, k;
string s;
int main() {
  cin >> n >> k >> s;
  string t = s;
  reverse(begin(t), end(t));
  string u = s + t;
  vector<string> ss;
  for (i64 i = 0; i < n; ++i) {
    string v = u.substr(i, n);
    reverse(begin(v), end(v));
    ss.push_back(v);
  }
  string w = *min_element(begin(ss), end(ss));
  i64 head_cnt = 1;
  for (i64 i = 1; i < n && w[i - 1] == w[i]; ++i) ++head_cnt;
  string tail = w.substr(head_cnt, n);
  i64 head_num = head_cnt;
  for (i64 i = 1; i < k && head_num <= n; ++i) head_num *= 2;
  string ans = (string(head_num, w[0]) + tail).substr(0, n);
  cout << ans << endl;
  return 0;
}
