defmodule Main do def main do [h, w] = IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1) hw = for _ <- 0..(h - 1), do: IO.read(:line) |> String.trim() |> String.split(" ") |> Enum.map(&String.to_integer/1) solve(h, w, hw) |> Enum.map(&(Enum.join(&1, " "))) |> Enum.join("\n") |> IO.puts() end def solve(_h, w, hw) do hw |> List.flatten() |> Enum.sort() |> Enum.chunk_every(w) end end