#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lint = long long;
const lint inf = 1e18 + 7;
const long long MOD = 1000000007;
long long myPow(long long x, long long n, long long rest) {
  long long res = 1;
  long long cur = x;
  while (n > 0) {
    if (n & 1) {
      res *= cur;
      res %= rest;
    }
    n /= 2;
    cur *= cur;
    cur %= rest;
  }
  return res;
}
signed main() {
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  string rev_s = s;
  reverse(rev_s.begin(), rev_s.end());
  s += rev_s;
  vector<long long> num(n * 2, 0);
  char mn = 'z' + 1;
  for (long long i = 0; i < n; ++i) mn = min(mn, s[i]);
  if (k == 1) {
    string res;
    res += 'z' + 1;
    for (long long i = 0; i < n + 1; ++i) {
      string buf = s.substr(i, n);
      res = min(res, buf);
    }
    cout << res << "\n";
    return 0;
  }
  long long cur = 0;
  s += '.';
  long long mx = -1;
  for (long long i = 0; i < n * 2 + 1; ++i) {
    if (cur == 0) {
      if (s[i] == mn)
        ++cur;
      else
        continue;
    } else {
      if (s[i] == mn)
        ++cur;
      else {
        num[i - 1] = cur;
        mx = max(mx, cur);
        cur = 0;
      }
    }
  }
  string res;
  res += 'z' + 1;
  string add;
  lint kazu = mx * myPow(2, k - 1, n + 1);
  for (long long i = 0; i < kazu; ++i) add += mn;
  for (long long i = n - 1; i <= 2 * n - 1; ++i) {
    if (num[i] == mx) {
      string buf = s.substr(i - (n - 1), n);
      buf += add;
      reverse(buf.begin(), buf.end());
      string hoge = buf.substr(mx, n);
      res = min(res, hoge);
    }
  }
  cout << res << "\n";
  return 0;
}
