#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
template <typename T, typename U>
istream &operator>>(istream &i, pair<T, U> &A) {
  i >> A.first >> A.second;
  return i;
}
template <typename T>
istream &operator>>(istream &i, vector<T> &A) {
  for (auto &I : A) {
    i >> I;
  }
  return i;
}
template <typename T, typename U>
ostream &operator<<(ostream &o, const pair<T, U> &A) {
  o << A.first << " " << A.second;
  return o;
}
template <typename T>
ostream &operator<<(ostream &o, const vector<T> &A) {
  long long int i = A.size();
  for (auto &I : A) {
    o << I << (--i ? " " : "");
  }
  return o;
}
vector<int> argmin_subseq(const vector<int> &seq, const int K) {
  vector<int> A = seq;
  const int mi = numeric_limits<int>::min();
  int N = A.size(), mx = mi, amx;
  assert(0 < K && K <= N);
  vector<int> idx, nx;
  for (auto &I : A) {
    I *= -1;
  }
  for (int i = 0; i + K <= N; i++) {
    mx = max(mx, A[i]);
  }
  for (auto &I : A) {
    I -= mx - 1;
  }
  for (int i = 0; i + K <= N; i++) {
    if (A[i] == 1) {
      idx.push_back(i);
    }
  }
  for (int len = 1; len < K;) {
    mx = mi;
    amx = -1;
    for (auto I : idx) {
      if (mx <= A[I + len]) {
        mx = A[I + len];
        amx = I;
      }
    }
    if (mx <= 0) {
      for (auto I : idx) {
        if (A[I + len] == mx) {
          A[I]++;
          nx.push_back(I);
        }
      }
      len++;
    } else {
      int ls = idx.back();
      if (ls + len + K > N) {
        for (int j = 0; j < mx && len + j < K; j++) {
          if (seq[amx + len + j] > seq[ls + len + j]) {
            return {ls};
          } else if (seq[amx + len + j] == seq[ls + len + j]) {
            A[ls]++;
          } else {
            break;
          }
        }
      }
      reverse(idx.begin(), idx.end());
      for (auto I : idx) {
        A[I] += max(0, min(A[I + len], K - len));
        mx = max(mx, A[I]);
      }
      reverse(idx.begin(), idx.end());
      for (auto I : idx) {
        if (A[I] == mx) {
          nx.push_back(I);
        }
      }
      len = mx;
    }
    idx.clear();
    swap(nx, idx);
  }
  return idx;
}
int main() {
  long long int N, K;
  cin >> N >> K;
  string s;
  cin >> s;
  string t = s;
  reverse(t.begin(), t.end());
  s += t;
  vector<int> A(s.size());
  for (int i = 0; i < (int)s.size(); i++) {
    A[i] = s[i];
  }
  vector<int> ret = argmin_subseq(A, N);
  int idx = ret[0];
  int cnt = 0, c = 0;
  for (int i = 0; i < N; i++) {
    if (A[idx] == A[idx + i]) {
      cnt++;
    } else {
      break;
    }
  }
  c = cnt;
  while (K > 1 && cnt < N) {
    cnt *= 2;
    K--;
  }
  string ans;
  for (int i = 0; i < cnt && i < N; i++) {
    ans += s[idx];
  }
  for (int i = cnt; i < N; i++) {
    ans += s[idx + c + (i - cnt)];
  }
  assert((int)ans.size() == N);
  cout << ans << endl;
  return 0;
}
