#include <bits/stdc++.h>
using namespace std;
const long long maxn = 3e5 + 7, mod = 998244353, inf = 1e18, MAXN = 1e6 + 7;
const double eps = 1e-9;
mt19937 rnd(time(0));
long long n, k;
string get(string s, long long k) {
  if (k == 0) return s;
  while (k > 1) {
    long long ln = 1;
    while (ln <= n && s[n - ln] == s[n - 1]) {
      ++ln;
    }
    --ln;
    string cur = "";
    for (long long i = ln; i < n; ++i) cur += s[i];
    for (long long i = 0; i < ln; ++i) cur += s[n - 1];
    s = cur;
    --k;
  }
  string cur1 = s;
  reverse(cur1.begin(), cur1.end());
  s += cur1;
  long long ln = 1;
  while (ln <= n && s[n - ln] == s[n - 1]) {
    ++ln;
  }
  --ln;
  string cur = "";
  for (long long i = 0; i < n; ++i) {
    cur += s[n - ln + i];
  }
  return cur;
}
void solve() {
  string s, a, p;
  long long ln = 1;
  char mn = 'z';
  cin >> n >> k >> s;
  a = s;
  reverse(a.begin(), a.end());
  p = s + a;
  k = min(k, 15ll);
  for (auto v : s) mn = min(v, mn);
  vector<long long> idd;
  for (long long i = 0; i < n;) {
    if (mn != s[i]) {
      ++i;
      continue;
    }
    long long sz = 0;
    long long i1 = i;
    while (i < n && s[i] == mn) {
      ++sz, ++i;
    }
    if (ln == sz) {
      idd.push_back(i1);
    } else if (ln < sz) {
      idd.clear();
      idd.push_back(i1);
      ln = sz;
    }
  }
  long long pw = 1;
  for (long long i = 0; i < k - 1; ++i) pw <<= 1;
  if (pw * ln >= n) {
    for (long long i = 0; i < n; ++i) cout << mn;
    return;
  }
  string ans = s;
  for (long long i = 0; i < n; ++i) {
    string cur = "";
    for (long long j = 0; j < n; ++j) cur += p[i + j];
    ans = min(ans, get(cur, k - 1));
  }
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
  cout << fixed;
  long long t = 1;
  for (long long i = 0; i < t; ++i) {
    solve();
  }
  return 0;
}
