#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;
  char s[10005];
  cin >> s;
  if (K == 1) {
    char t[10005];
    for (int i = 0; i < N; ++i) {
      t[i] = s[N - i - 1];
    }
    t[N] = '\0';
    char res[10005];
    strcpy(res, s);
    strcat(s, t);
    char tmp[10005];
    for (int i = 1; i < N; ++i) {
      for (int j = i; j < i + N; ++j) {
        tmp[j - i] = s[j];
      }
      if (strcmp(res, tmp) > 0) strcpy(res, tmp);
    }
    cout << res << endl;
    return 0;
  }
  char res[10005], t[10005], tmp[10005];
  for (int i = 0; i < N; ++i) {
    t[i] = s[N - i - 1];
  }
  t[N] = '\0';
  strcpy(res, s);
  strcat(s, t);
  for (int i = N * 2 - 1; i >= N; --i) {
    for (int j = i; j > i - N; --j) {
      tmp[i - j] = s[j];
    }
    if (strcmp(res, tmp) > 0) strcpy(res, tmp);
  }
  --K;
  int l, r;
  while (K > 1) {
    int pos = N - 1;
    while (pos >= 0 && res[N - 1] == res[pos]) {
      t[pos] = res[pos];
      --pos;
    }
    if (pos == -1) {
      cout << res << endl;
      return 0;
    }
    int p = N - 1;
    while (pos >= 0) {
      t[pos] = res[p];
      --pos, --p;
    }
    strcpy(res, t);
    --K;
  }
  strcpy(t, res);
  l = 0, r = N - 1;
  while (l < r) {
    swap(res[l], res[r]);
    ++l;
    --r;
  }
  strcpy(s, res);
  strcat(res, t);
  for (int i = 0; i < N; ++i) {
    for (int j = i; j < i + N; ++j) {
      tmp[j - i] = res[j];
    }
    if (strcmp(s, tmp) > 0) strcpy(s, tmp);
  }
  cout << s << endl;
  return 0;
}
