#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <typename T1, typename T2>
inline void chkmin(T1 &first, T2 second) {
  if (first > second) first = second;
}
template <typename T1, typename T2>
inline void chkmax(T1 &first, T2 second) {
  if (first < second) first = second;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const pair<T, U> &_p) {
  _out << _p.first << ' ' << _p.second;
  return _out;
}
template <typename T, typename U>
inline istream &operator>>(istream &_in, pair<T, U> &_p) {
  _in >> _p.first >> _p.second;
  return _in;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const vector<T> &_v) {
  if (_v.empty()) {
    return _out;
  }
  _out << _v.front();
  for (auto _it = ++_v.begin(); _it != _v.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T>
inline istream &operator>>(istream &_in, vector<T> &_v) {
  for (auto &_i : _v) {
    _in >> _i;
  }
  return _in;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const set<T> &_s) {
  if (_s.empty()) {
    return _out;
  }
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const multiset<T> &_s) {
  if (_s.empty()) {
    return _out;
  }
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const unordered_set<T> &_s) {
  if (_s.empty()) {
    return _out;
  }
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T>
inline ostream &operator<<(ostream &_out, const unordered_multiset<T> &_s) {
  if (_s.empty()) {
    return _out;
  }
  _out << *_s.begin();
  for (auto _it = ++_s.begin(); _it != _s.end(); ++_it) {
    _out << ' ' << *_it;
  }
  return _out;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const map<T, U> &_m) {
  if (_m.empty()) {
    return _out;
  }
  _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')';
  for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) {
    _out << ", (" << _it->first << ": " << _it->second << ')';
  }
  return _out;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &_out, const unordered_map<T, U> &_m) {
  if (_m.empty()) {
    return _out;
  }
  _out << '(' << _m.begin()->first << ": " << _m.begin()->second << ')';
  for (auto _it = ++_m.begin(); _it != _m.end(); ++_it) {
    _out << ", (" << _it->first << ": " << _it->second << ')';
  }
  return _out;
}
const int N = 1e6 + 5;
const int p = 998244353;
int mul(long long a, int b) { return a * b % p; }
int n, k;
string s;
string ans;
int a[N], b[N];
vector<int> ord;
void find_smallest() {
  string cur = s;
  reverse(s.begin(), s.end());
  cur += s;
  cur += '#';
  for (int i = 0; i < cur.size(); ++i) a[i] = cur[i];
  sort(ord.begin(), ord.end(), [&](int i, int j) { return cur[i] < cur[j]; });
  for (int i = 0; (1 << i) < cur.size(); ++i) {
    for (int j = 0; j < cur.size(); ++j) {
      b[j] = a[(j + (1 << i)) % cur.size()];
    }
    int cnt = 0;
    int L = 0;
    while (L < cur.size()) {
      int R = L;
      while (R < cur.size() && a[ord[L]] == a[ord[R]]) ++R;
      sort(ord.begin() + L, ord.begin() + R,
           [&](int i, int j) { return b[i] < b[j]; });
      a[ord[L]] = cnt;
      for (int M = L + 1; M < R; ++M) {
        if (b[ord[M - 1]] != b[ord[M]]) ++cnt;
        a[ord[M]] = cnt;
      }
      ++cnt;
      L = R;
    }
  }
  for (int i : ord) {
    if (i + n < cur.size()) {
      s = "";
      for (int j = 0; j < n; ++j) {
        s += cur[i + j];
      }
      return;
    }
  }
  assert(false);
}
int main() {
  ios::sync_with_stdio(0);
  srand(time(0));
  cin >> n >> k;
  cin >> s;
  chkmin(k, 15);
  for (int i = 0; i < n * 2; ++i) ord.push_back(i);
  for (int i = 0; i < k; ++i) {
    find_smallest();
    if (i + 1 != k) reverse(s.begin(), s.end());
  }
  cout << s << '\n';
}
