import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val (h, w) = (sc.nextInt, sc.nextInt)
  val xs = Vector.fill(h)(sc.next.toCharArray).flatten
  val idx = {
    for {
      i <- 1 to h
      j <- 1 to w
    } yield (i, j)
  } zip xs

  val mx = idx.foldLeft((Map.empty[(Int, Int), Char], Set.empty[Int], Set.empty[Int])) { (acc, next) =>
    val c = next._2
    val black = c == '#'
    val h = if (black) acc._2 + next._1._1 else acc._2
    val w = if (black) acc._3 + next._1._2 else acc._3
    (acc._1.updated(next._1, c), h, w)
  }
  for {
    i <- 1 to h if mx._2.contains(i)
  } {
    for {
      j <- 1 to w if mx._3.contains(j)
    } {
      print(mx._1((i, j)))
    }
    println()
  }
}
