import algorithm, future, hashes, macros, math, sequtils, sets, strutils, tables, times, unicode, queues
 
macro unpack(rhs: seq, cnt: static[int]): auto =
  let t = genSym(); result = quote do:(let `t` = `rhs`;())
  if NimMinor <= 17:
    for i in 0..<cnt: result[0][1].add(quote do:`t`[`i`])
  else:
    for i in 0..<cnt: result[1].add(quote do:`t`[`i`])
 
template input(T: typedesc, cnt: Natural = 1): untyped =
  let line = stdin.readLine.split(" ")
  when T is int:         line.map(parseInt).unpack(cnt)
  elif T is float:       line.map(parseFloat).unpack(cnt)
  elif T is string:      line.unpack(cnt)
  elif T is char:        line.mapIt(it[0]).unpack(cnt)
  elif T is seq[int]:    line.map(parseInt)
  elif T is seq[float]:  line.map(parseFloat)
  elif T is seq[string]: line
  elif T is seq[char]:   line.mapIt(it[0])

proc floorMod*[T: SomeNumber](x, y: T): T =
  result = x mod y
  if (result > 0 and y < 0) or (result < 0 and y > 0): result += y

proc `%=`(n: var int, m: int)  = n = floorMod(n,m)
proc `//=`(n: var int, m: int) = n = n div m
proc `<<=`(n: var int, m: int) = n = n shl m
proc `>>=`(n: var int, m: int) = n = n shr m
proc `<?=`(n: var int, m: int) = n = min(n, m)
proc `>?=`(n: var int, m: int) = n = max(n, m)
proc newSeq2[T](n1, n2: Natural): seq[seq[T]] = newSeqWith(n1, newSeq[T](n2))
proc newSeq3[T](n1, n2, n3: Natural): seq[seq[seq[T]]] = newSeqWith(n1, newSeqWith(n2, newSeq[T](n3)))
 
# -------------------------------------------------- #


var (N,K) = input(int,2)

if K > 15: # K dekaito 2^K keisan de bug risou nanode
  echo a.repeat(N)
  quit()

var S = input(string)
var T = S.reversed()
var ST = S & T
var a = '~' # nazeka atcoder deha min(string):string
for x in S:
  if x < a:
    a = x
var arepTn = newSeq[int](2*N+1)
var L = 0
arepTn[0] = 0
for i in 0..<2*N:
  if ST[i]==a:
    arepTn[i+1] = arepTn[i]+1
    L >?= arepTn[i+1]
  else:
    arepTn[i+1] = 0

var finalARep = L * 2^(K-1)
if finalARep >= N:
  echo a.repeat(N)
  quit()

var firstSuffixs = newSeq[string]()
for i in N..(2*N):
  if arepTn[i]==L:
    firstSuffixs.add(ST[(i-N)..<i])

var finalSuffixs = newSeq[string]()
for first in firstSuffixs:
  var final = first[(finalARep-L)..<(N-L)] & a.repeat(finalARep)
  finalSuffixs.add(final)

var bestFirstPrefix = "~~~"
for suf in finalSuffixs:
  let prf = suf.reversed()
  if bestFirstPrefix > prf:
    bestFirstPrefix = prf

echo bestFirstPrefix