#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;
static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;
const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};
vector<LL> Div(LL n) {
  vector<LL> ret;
  for (LL i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  string s;
  cin >> s;
  string t = s;
  reverse(t.begin(), t.end());
  string res = s;
  s += t;
  if (K == 1) {
    for (int i = 1; i < s.size() - N; ++i) {
      string tmp;
      for (int j = i; j < i + N; ++j) {
        string tt = {s[j]};
        tmp += tt;
      }
      if (res > tmp) res = tmp;
    }
    cout << res << endl;
    return 0;
  }
  for (int i = s.size() - 1; i >= N; --i) {
    string tmp;
    for (int j = i; j > i - N; --j) {
      string ttmp = {s[j]};
      tmp += ttmp;
    }
    res = min(res, tmp);
  }
  reverse(res.begin(), res.end());
  --K;
  while (K > 1) {
    t = res;
    string tmp;
    int pos = res.size() - 1;
    while (pos >= 0 && res[pos] == res[res.size() - 1]) {
      string ttmp = {res[pos]};
      tmp += ttmp;
      --pos;
    }
    if (pos < 0) {
      cout << res << endl;
      return 0;
    }
    pos = res.size() - 1;
    while (tmp.size() < N) {
      string ttmp = {res[pos]};
      tmp += ttmp;
      --pos;
    }
    reverse(tmp.begin(), tmp.end());
    res = tmp;
    --K;
  }
  t = res;
  reverse(t.begin(), t.end());
  string mn = res;
  res += t;
  for (int i = 1; i < res.size() - N; ++i) {
    string tmp;
    for (int j = i; j < i + N; ++j) {
      string ttmp = {res[j]};
      tmp += ttmp;
    }
    if (mn > tmp) mn = tmp;
  }
  cout << mn << endl;
  return 0;
}
