#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 s;
string a, p;
string get(long long idd, long long ln, long long mn) {
  long long k1 = k;
  string cur = "";
  if (k1 == 1) {
    for (long long i = idd; i < idd + n; ++i) {
      cur += p[i];
    }
    return cur;
  }
  long long lnn = ln;
  for (long long i = n - idd; i < n; ++i) {
    cur += s[i];
  }
  for (long long i = n - 1; i >= idd; --i) {
    cur += s[i];
  }
  string ans = "";
  --k1;
  for (long long i = 0; i < k1; ++i) {
    ln <<= 1;
  }
  for (long long i = 0; i < ln; ++i) {
    ans += mn;
  }
  long long ms = n - lnn - 1;
  for (long long i = 0; i < n - ln; ++i) {
    ans += cur[ms--];
  }
  return ans;
}
void solve() {
  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 (auto v : idd) {
    ans = min(ans, get(v, ln, mn));
  }
  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;
}
