import algorithm, sequtils, strutils var h, w: int (h, w) = stdin.readLine.split.map parseInt let xs = sorted concat h.newSeqWith stdin.readLine.split.map parseInt echo distribute(xs, h).mapIt(it.join " ").join "\n"