object Main extends App {
  val Array(h,w) = io.StdIn.readLine.split(' ').map(_.toInt)

  val as =  for (i <- 0 until h) yield for (s <- io.StdIn.readLine) yield s

  val ngCol = (0 until as.head.size).filter(i => as.forall(s => s(i) == '.'))

  for (a <- as if !a.forall(_ == '.'))
    println((0 until as.head.size).filter(!ngCol.contains(_)).map(a).mkString)

}
