#include <bits/stdc++.h>
using namespace std;
vector<int> construct_sa(const string& S) {
  vector<int> SA, ranks, tmp;
  int N = S.length();
  SA.resize(N + 1);
  ranks.resize(N + 1);
  tmp.resize(N + 1);
  for (int i = 0; i <= N; i++) {
    SA[i] = i;
    ranks[i] = (i < N ? S[i] : -1);
  }
  for (int k = 1; k <= N; k *= 2) {
    auto f = [&](const int& a, const int& b) {
      if (ranks[a] != ranks[b])
        return ranks[a] < ranks[b];
      else {
        int ra = (a + k <= N ? ranks[a + k] : -1);
        int rb = (b + k <= N ? ranks[b + k] : -1);
        return ra < rb;
      }
    };
    sort(SA.begin(), SA.end(), f);
    tmp[SA[0]] = 0;
    for (int i = 1; i <= N; i++) {
      tmp[SA[i]] = tmp[SA[i - 1]] + (f(SA[i - 1], SA[i]) ? 1 : 0);
    }
    for (int i = 0; i <= N; i++) {
      ranks[i] = tmp[i];
    }
  }
  return SA;
}
string calcmns(const string& S) {
  int N = S.size();
  vector<int> SA = construct_sa(S);
  for (long long i = (long long)(0); i < (long long)(SA.size()); i++) {
    if (SA[i] <= N / 2) {
      return S.substr(SA[i], N / 2);
    }
  }
  return "~";
}
string calcU(const string& S) {
  string T = S;
  reverse((T).begin(), (T).end());
  return S + T;
}
long long N, K;
string S;
char mnc = '~';
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> K >> S;
  for (long long i = (long long)(0); i < (long long)(N); i++)
    mnc = (mnc < S[i] ? mnc : S[i]);
  string T = S;
  reverse((T).begin(), (T).end());
  string U = S + T;
  K = min(K, 14LL);
  string res = "~";
  for (long long i = (long long)(N - 1); i < (long long)(2 * N); i++) {
    if (U[i] == mnc) {
      string crtS = S;
      for (long long j = (long long)(0); j < (long long)(K - 1); j++) {
        string crtU = calcU(crtS);
        long long k;
        if (j > 0) {
          k = N;
          while (k < 2 * N && crtU[k] == mnc) k++;
        } else {
          k = i + 1;
        }
        crtS = crtU.substr(k - N, N);
      }
      res = (res < calcmns(calcU(crtS)) ? res : calcmns(calcU(crtS)));
    }
  }
  cout << res << endl;
  return 0;
}
