fun main(args:Array<String>) {
	val (h,w) = readLine()!!.split(" ").map{ it.toInt() }
	val a = (1..h).map{ readLine()!! }
	val xb = BooleanArray(w){ x-> a.any{ it[x]=='#' } }
	val yb = BooleanArray(h){ y-> a[y].contains('#') }
	
	for(i in 0..h-1){
		if(!yb[i]) continue
		for(j in 0..w-1){
			if(xb[j]) print(a[i][j])
		}
		println()
	}
	
}