import java.io.{BufferedReader, InputStreamReader}

object Main extends App {
  val in = new BufferedReader(new InputStreamReader(System.in))
  val out = new java.io.PrintWriter(System.out)

  Iterator.continually(in.readLine)
    .drop(1)
    .takeWhile(_ != null)
    .filter(_.contains('#'))
    .map(_.toCharArray)
    .toArray
    .transpose
    .filter(_.contains('#'))
    .transpose
    .foreach(ch => out.println(ch.mkString))
  out.flush
}