import scala.io.StdIn._
import scala.math._

/**
 * ABC107B
 */
object Main extends App {

  val Seq(h, w) = readLine().split(" ").toSeq.map(_.toInt)
  val blob: Seq[String] = (0 until h).map(_ => readLine()).toIndexedSeq

  val calcNewRow = (b: String) => {
    (0 until w)
      .filter(colNum => blob.map(_(colNum).toString).contains("#"))
      .map(v => b(v))
      .mkString("")
  }

  val ans = blob.filter(v => v.contains("#"))
    .map(calcNewRow(_))

  ans.foreach(println)

}
