#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
Int n,k;
string calc(string s){
  reverse(s.begin(),s.end());
  Int cnt=0;
  while(cnt<n&&s[0]==s[cnt]) cnt++;
  Int len=cnt<<k;
  if(len>=n) return string(n,s[0]);
  string res;
  for(Int i=cnt;i<n;i++)
    if(len+(Int)res.size()<n) res+=s[i];
  return string(len,s[0])+res;
}

signed main(){
  string s;
  cin>>n>>k>>s;
  chmin(k,20);
  k--;
  string ans=s;

  string t(s);
  reverse(t.begin(),t.end());
  string b=s+t;
  for(Int i=0;i<=n;i++){
    string c=b.substr(i,n);
    chmin(ans,calc(c));
  }
  cout<<ans<<endl;
  return 0;
}
