#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}


vector<int> argmin_subseq(const vector<int> &seq,const int K){
  vector<int> A=seq;
  const int mi=numeric_limits<int>::min();
  int N=A.size(),mx=mi,amx;
  assert(0<K && K<=N);
  vector<int> idx,nx;
  for(auto &I:A){I*=-1;}
  for(int i=0;i+K<=N;i++){mx=max(mx,A[i]);}
  for(auto &I:A){I-=mx;}
  for(int i=0;i+K<=N;i++){
    if(A[i]==0){A[i]++; idx.push_back(i);}
  }
  for(int len=1;len<K;){
    mx=mi;
    amx=-1;
    for(auto I:idx){
      if(mx<=A[I+len]){
        mx=A[I+len];
        amx=I;
      }
    }
    if(mx<=0){
      for(auto I:idx){
        if(A[I+len]==mx){A[I]++; nx.push_back(I);}
      }
      len++;
    }
    else{
      reverse(idx.begin(),idx.end());
      int ls=idx[0];
      if(ls+len+K>N && amx+len==ls){
        for(int j=0;len+j<K;j++){
          if(seq[amx+len+j]>seq[ls+len+j]){return {ls};}
          else if(seq[amx+len+j]==seq[ls+len+j]){A[ls]++;}
          else{break;}
        }
        for(auto I:idx){
          A[I]+=max(0,min(A[I+len],K-len));
          mx=max(mx,A[I]);
        }
      }
      else if(ls+len+K>N){
        for(auto I:idx){
          A[I]+=max(0,min(A[I+len],K-len));
          mx=max(mx,A[I]);
        }
        for(int j=0;j<mx && len+j<K;j++){
          if(seq[amx+len+j]>seq[ls+len+j]){return {ls};}
          else if(seq[amx+len+j]==seq[ls+len+j]){A[ls]++;}
          else{break;}
        }
      }
      else{
        for(auto I:idx){
          A[I]+=max(0,min(A[I+len],K-len));
          mx=max(mx,A[I]);
        }
      }
      reverse(idx.begin(),idx.end());
      for(auto I:idx){
        if(A[I]==mx){nx.push_back(I);}
      }
      len=mx;
    }
    idx.clear();
    swap(nx,idx);
  }
  return idx;
}

vector<int> argmin2(string s,int N){
  vector<int> ret;
  string mi=s.substr(0,N);
  for(int i=1;i<=N;i++){mi=min(mi,s.substr(i,N));}
  for(int i=0;i<=N;i++){
    if(mi==s.substr(i,N)){ret.push_back(i);}
  }
  return ret;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,K;
  cin>>N>>K;
  string s;
  cin>>s;
  string t=s;
  reverse(t.begin(),t.end());
  s+=t;
  vector<int> A(s.size());
  for(int i=0;i<(int)s.size();i++){A[i]=(int)s[i];}
  vector<int> ret=argmin_subseq(A,N);
  //vector<int> ret2=argmin2(s,N);
  //assert(ret==ret2);
  int idx=ret[0];
  int cnt=0,c=0;
  for(int i=0;i<N;i++){
    if(A[idx]==A[idx+i]){cnt++;}
    else{break;}
  }
  c=cnt;
  while(K>1 && cnt<N){cnt*=2; K--;}
  string ans;
  for(int i=0;i<cnt && i<N;i++){ans+=s[idx];}
  for(int i=cnt;i<N;i++){ans+=s[idx+c+(i-cnt)];}
  cout<<ans<<endl;

  
  return 0;
}


Measured memory_bytes: 384