#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
  int n;
  ll k;
  string s;
  cin>>n>>k>>s;
  string copy=s;
  sort(copy.begin(),copy.end());
  string copyb=copy;
  string copyc=s;
  string copyd=s;
  string copye;
  reverse(copyd.begin(),copyd.end());
  for(int i=0;i<n;i++){
    copyb[i]=copy[n-1];
  }
  string copyf=copyb;
  if(k>=15){
    for(int i=0;i<n;i++){
      cout<<copy[0];
    }
    cout<<endl;
    return 0;
  }
  for(int i=0;i<k-1;i++){
    s=copyc+copyd;
    for(int j=0;j<=n;j++){
      copye=s.substr(j,n);
      reverse(copye.begin(),copye.end());
      if(copyb>copye){
        copyb=copye;
      }
    }
    copyc=copyb;
    copyd=copyc;
    reverse(copyc.begin(),copyc.end());
    copyb=copyf;
  }
  //cout<<copyc<<" "<<copyd<<endl;
  s=copyc+copyd;
  for(int i=0;i<=n;i++){
    copye=s.substr(i,n);
    if(copyb>copye){
      copyb=copye;
    }
  }
  cout<<copyb<<endl;
}