#include<bits/stdc++.h>
#define rep(i,a,b) for (int i = (a); i <= (b); ++i)
#define drep(i,a,b) for (int i = (a); i >= (b); --i)
#define grep(i,u) for (int i = head[u],v = e[i].v; i; v = e[i = e[i].nxt].v)
#define il inline
#define LL long long
#define ULL unsigned LL
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
il LL read() {
	LL res = 0,f = 1; char ch = getchar(); while (!isdigit(ch)) {if (ch == '-') f = -f; ch = getchar();}
	while (isdigit(ch)) {res = res*10+ch-'0'; ch = getchar();} return res*f;
}
namespace qiqi {
	const int N = 1e4+5; int n,m,k; char s[N]; 
	void main() {
		n = read(); m = n<<1; k = read(); int x = 0,y; while ((1<<x) < n) ++x; k = min(k,x); scanf("%s",s+1); rep(i,1,n) s[m-i+1] = s[i];
		x = 1; while (x <= n) {int i = y = x,j = x+1; while (j <= m && s[i] <= s[j]) i = s[i] < s[j++] ? x : i+1; while (x <= i) x += j-i;}
		rep(i,1,n) s[i] = s[i+y-1]; s[n+1] = x = 0; rep(i,1,n) {++x; if (s[i] != s[i+1]) break;} y = min(x<<(k-1),n); drep(i,n,y+1) s[i] = s[i-y+x]; rep(i,1,y) s[i] = s[1]; puts(s+1);
	}
}
int main() {
	qiqi::main(); return 0;
}