object Main extends App{
    val Array(h, w) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
    val MM = Array.ofDim[Int](h, w)

    for(i<-0 until h){
    	MM(i) = scala.io.StdIn.readLine.toList.toArray.map{
    		case '#' => 1
    		case '.' => 0
    	}
    }

    var row = List[Int]()
    var col = List[Int]()

    for(i<-0 until w){
    	var tp = 0
    	for(j<-0 until h){
    		tp += MM(j)(i)
    	}
    	if(tp != 0){
    		row = i :: row
    	}
    }

    for(i<-0 until h){
    	if(MM(i).sum != 0){
    		col = i :: col
    	}
    }

    for(i<-col.sorted){
    	for(j<-row.sorted){
    		if(MM(i)(j) == 0){
    			print(".")
    		}else{
    			print("#")
    		}
    	}
    	print("\n")
    }

}