#include <bits/stdc++.h>
using namespace std;
template <class A>
void pr(A a) {
  cout << a;
  cout << '\n';
}
template <class A, class B>
void pr(A a, B b) {
  cout << a << ' ';
  pr(b);
}
template <class A, class B, class C>
void pr(A a, B b, C c) {
  cout << a << ' ';
  pr(b, c);
}
template <class A, class B, class C, class D>
void pr(A a, B b, C c, D d) {
  cout << a << ' ';
  pr(b, c, d);
}
template <class A>
void PR(A a, long long n) {
  for (long long i = (long long)(0); i < (long long)(n); i++) {
    if (i) cout << ' ';
    cout << a[i];
  }
  cout << '\n';
}
long long check(long long n, long long m, long long x, long long y) {
  return x >= 0 && x < n && y >= 0 && y < m;
}
const long long MAX = 1e9 + 7, MAXL = 1LL << 61, dx[4] = {-1, 0, 1, 0},
                dy[4] = {0, 1, 0, -1};
void sa_is_countingAlphabets(const int *s, int n, int size, vector<int> &b,
                             bool f = false) {
  if (f || (int)b.size() / 2 >= size) {
    vector<int>::iterator a = f ? b.begin() : b.begin() + size;
    fill(a, a + size, 0);
    for (int i = 0; i < n; i++) a[(int)s[i]]++;
  }
}
void sa_is_getBucketOffsets(const int *s, int n, bool dir, int size,
                            vector<int> &b) {
  vector<int>::iterator a;
  if ((int)b.size() / 2 < size) {
    sa_is_countingAlphabets(s, n, size, b, true);
    a = b.begin();
  } else
    a = b.begin() + size;
  int cumsum = 1;
  if (dir) {
    for (int i = 0; i < size; i++) {
      cumsum += a[i];
      b[i] = cumsum;
    }
  } else {
    for (int i = 0; i < size; i++) {
      int x = a[i];
      b[i] = cumsum;
      cumsum += x;
    }
  }
}
void sa_is_inducedSort(const int *s, int n, int size, const vector<bool> &types,
                       int *sa, vector<int> &b) {
  sa_is_getBucketOffsets(s, n, false, size, b);
  for (int i = 0; i < n; i++) {
    int j = sa[i] - 1;
    if (j >= 0 && !types[j]) sa[b[(int)s[j]]++] = j;
  }
  sa_is_getBucketOffsets(s, n, true, size, b);
  for (int i = n; i >= 1; i--) {
    int j = sa[i] - 1;
    if (j >= 0 && types[j]) sa[--b[(int)s[j]]] = j;
  }
}
void sa_is_rec(const int *s, int n, int size, int *sa, vector<int> &b) {
  vector<bool> types(n + 1);
  types[n - 1] = 0;
  types[n] = 1;
  for (int i = n - 2; i >= 0; i--)
    types[i] = s[i] < s[i + 1] || (s[i] == s[i + 1] && types[i + 1]);
  sa_is_countingAlphabets(s, n, size, b);
  sa_is_getBucketOffsets(s, n, true, size, b);
  fill(sa, sa + n + 1, -1);
  for (int i = 1; i < n; i++)
    if (types[i] && !types[i - 1]) sa[--b[(int)s[i]]] = i;
  sa[0] = n;
  sa_is_inducedSort(s, n, size, types, sa, b);
  int n1 = 0;
  for (int i = 0; i <= n; i++) {
    int j = sa[i];
    if (j > 0 && types[j] && !types[j - 1]) sa[n1++] = j;
  }
  int *buffer = sa + n1;
  fill(buffer, sa + n + 1, -1);
  int c = 0, ppos = -1;
  buffer[sa[0] / 2] = c++;
  for (int i = 1; i < n1; i++) {
    int pos = sa[i];
    bool diff = false;
    if (ppos == -1)
      diff = true;
    else {
      for (int j = pos, k = ppos;; j++, k++) {
        if (s[j] != s[k] || types[j] != types[k]) {
          diff = true;
          break;
        } else if (j != pos &&
                   ((types[j] && !types[j - 1]) || (types[k] && !types[k - 1])))
          break;
      }
    }
    if (diff) {
      c++;
      ppos = pos;
    }
    buffer[pos / 2] = c - 1;
  }
  for (int i = n, j = n; i >= n1; i--)
    if (sa[i] >= 0) sa[j--] = sa[i];
  int *sa1 = sa, *s1 = sa + n + 1 - n1;
  if (c == n1)
    for (int i = 0; i < n1; i++) sa1[s1[i]] = i;
  else
    sa_is_rec(s1, n1 - 1, c, sa1, b);
  sa_is_countingAlphabets(s, n, size, b);
  sa_is_getBucketOffsets(s, n, true, size, b);
  for (int i = 1, j = 0; i <= n; i++)
    if (types[i] && !types[i - 1]) s1[j++] = i;
  for (int i = 0; i < n1; i++) sa1[i] = s1[sa1[i]];
  fill(sa + n1, sa + n + 1, -1);
  for (int i = n1 - 1; i >= 1; i--) {
    int j = sa[i];
    sa[i] = -1;
    sa[--b[(int)s[j]]] = j;
  }
  sa_is_inducedSort(s, n, size, types, sa, b);
}
void buildSuffixArray(const int *s, int n, int size, int *sa) {
  if (n == 0)
    sa[0] = 0;
  else {
    vector<int> b(max(size, (n + 1) / 2) + 1);
    sa_is_rec(s, n, size, &sa[0], b);
  }
}
void buildSuffixArray(const string s, int n, int *sa) {
  int a[n];
  for (int i = 0; i < n; i++) a[i] = (int)s[i];
  int maxElem = *max_element(a, a + n);
  buildSuffixArray(a, n, maxElem + 1, sa);
}
const int MAXN = 10010;
int sa[MAXN];
string ans = "{";
long long n;
void dfs(string s, long long m, long long f) {
  if (!m) {
    ans = min(ans, s);
    return;
  }
  string t = s;
  reverse((t).begin(), (t).end());
  s += t;
  string s1, s2;
  buildSuffixArray(s, s.size(), sa);
  for (long long i = (long long)(0); i < (long long)(s.size()); i++) {
    if (sa[i] < n) {
      s1 = s.substr(sa[i], n);
      break;
    }
  }
  reverse((s).begin(), (s).end());
  buildSuffixArray(s, s.size(), sa);
  for (long long i = (long long)(0); i < (long long)(s.size()); i++) {
    if (sa[i] < n) {
      s2 = s.substr(sa[i], n);
      reverse((s2).begin(), (s2).end());
      break;
    }
  }
  if (m < 5 || f > 0) {
    dfs(s1, m - 1, f - 1);
    dfs(s2, m - 1, f - 1);
  } else {
    reverse((s2).begin(), (s2).end());
    if (s1 <= s2)
      dfs(s1, m - 1, f - 1);
    else {
      reverse((s2).begin(), (s2).end());
      dfs(s2, m - 1, f - 1);
    }
  }
}
void Main() {
  long long m;
  string s;
  cin >> n >> m >> s;
  m = min(m, 14LL);
  dfs(s, m, 5);
  pr(ans);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  Main();
  return 0;
}
