'use strict'

function main(input) {
	input = input.split('\n')
	const head = input[0].split(' ')
	const H = ~~head[0]
	const W = ~~head[1]

	const graph = input.slice(1, input.length) //.map(v => v.split(""))
	let rows = Array.apply(null, { length: H }).map(v => false)
	let cols = Array.apply(null, { length: W }).map(v => false)
	for (let r in graph) {
		//行のマークテスト
		if (/#/.test(graph[r])) {
			//r行に#あり
			rows[r] = true
			for (let c in graph[r]) {
				//この列に#あり
				if (!cols[c] && graph[r][c] == '#') cols[c] = true
			}
		}
	}
	let ans = ''

	for (let r in rows) {
		if (rows[r]) {
			//どちらもtrueならgraphから値を取得、
			for (let c in cols) {
				if (cols[c]) {
					ans += graph[r][c]
				}
			}
			ans += '\n'
		}
	}

	console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))
