#include <bits/stdc++.h>
using namespace std;
template <class T>
void scan(T &a) {
  cin >> a;
}
template <class T>
void scan(vector<T> &a) {
  for (auto &i : a) scan(i);
}
template <class T, class L>
void scan(pair<T, L> &p) {
  scan(p.first);
  scan(p.second);
}
void IN() {}
template <class Head, class... Tail>
void IN(Head &head, Tail &...tail) {
  scan(head);
  IN(tail...);
}
template <class T>
inline void print(T x) {
  cout << x << '\n';
}
template <class T = long long>
using V = vector<T>;
template <class T = long long>
using VV = V<V<T>>;
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
inline void Yes(bool b = true) { cout << (b ? "Yes" : "No") << '\n'; }
inline void YES(bool b = true) { cout << (b ? "YES" : "NO") << '\n'; }
inline void err(bool b = true) {
  if (b) {
    cout << -1 << '\n';
    exit(0);
  }
}
template <class T>
inline void fin(bool b = true, T e = 0) {
  if (b) {
    cout << e << '\n';
    exit(0);
  }
}
template <class T>
T Roundup_div(T x, T y) {
  return (x + (y - 1)) / y;
}
template <typename T>
T pow(T a, long long n, T e = 1) {
  T ret = e;
  while (n) {
    if (n & 1) ret *= a;
    a *= a;
    n >>= 1;
  }
  return ret;
}
const long long INF = 1e18;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ;
  int n, k;
  IN(n, k);
  string s;
  IN(s);
  string t = s;
  reverse((t).begin(), (t).end());
  s += t;
  char mini = 'z';
  for (long long i = (0); i < (2 * n); ++i) chmin(mini, s[i]);
  int max_len = 0, cnt = 0;
  for (long long i = (0); i < (2 * n); ++i) {
    if (s[i] == mini)
      cnt++;
    else
      cnt = 0;
    chmax(max_len, cnt);
  }
  if (k > 13 or max_len * pow(2, k - 1) >= n) {
    for (long long i = (0); i < (n); ++i) cout << mini;
    cout << endl;
    return 0;
  }
  string res = "", ok = "", top = "";
  for (long long i = (0); i < (n); ++i) res += 'z';
  for (long long i = (0); i < (max_len); ++i) ok += mini;
  for (long long i = (0); i < (pow(2, k - 1)); ++i) top += ok;
  for (long long i = (0); i < (n); ++i) {
    if (s.substr(i + n - max_len, max_len) != ok) continue;
    string d = s.substr(i + max_len * (pow(2, k - 1) - 1),
                        n - max_len * pow(2, k - 1));
    reverse((d).begin(), (d).end());
    chmin(res, top + d);
  }
  print(res);
}
