object Main extends App{
    val sc = new java.util.Scanner(System.in)
    val h, w = sc.nextInt
    val list = List.fill(h)(sc.next)
    val colBuf = (0 until w).map(x => {
        (0 until h).foldLeft(true)((acc, y) => acc && list(y)(x) == '.')
    })
    val rowBuf = (0 until h).map(y => {
        (0 until w).foldLeft(true)((acc, x) => acc && list(y)(x) == '.')
    })

    (0 until h).foreach(y => {
        (0 until w).foreach(x => {
            if(!colBuf(x) && !rowBuf(y)) {
                print(s"${list(y)(x)}")
        }})
        if(!rowBuf(y)) {
            println("")
        }
    })
}
