//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()
#define pb push_back

#define error(x) cout << #x << " = " << x << endl

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

const int N = 5000 + 20 ;
int n , k ;
string s ;

int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0) ;

	cin >> n >> k ;
	cin >> s ;

	string t = s , m = s ;
	reverse(t.begin() , t.end()) ;

	s += t ;

	for (int i = 0 ; i < n ; i ++)
		m = min(m , s.substr(i , n)) ;

	int a = 0 , b = 0 ;
	while (a < n && m[0] == m[a]) a ++ ;

	k -- ;

	if (k > 20 || (a << k) > n) b = n ;
	else b = a << k ;

	for (int i = 0 ; i < b ; i ++) cout << m[0] ;
	cout << m.substr(a , n - b) ;
	cout << '\n' ;
}
