local read = io.read
local concat = table.concat
local char = string.char

local h, w = read("n", "n", "l")
local black = string.byte("#")

local a_t = {}
for i = 1, h do
	a_t[i] = read()
end

local del_i_t = {}
for i = 1, h do
	local is_breaked = false
	for j = 1, w do
		if a_t[i]:byte(j) == black then
			is_breaked = true
			break
		end
	end
	if not is_breaked then
		del_i_t[i] = true
	end
end

local del_j_t = {}
for j = 1, w do
	local is_breaked = false
	for i = 1, h do
		if a_t[i]:byte(j) == black then
			is_breaked = true
			break
		end
	end
	if not is_breaked then
		del_j_t[j] = true
	end
end

local copy_a_t = {}
local last_i = 0
for i = 1, h do
	if not del_i_t[i] then
		last_i = last_i + 1
		local last_j = 0
		copy_a_t[last_i] = {}
		for j = 1, w do
			if not del_j_t[j] then
				last_j = last_j + 1
				copy_a_t[last_i][last_j] = a_t[i]:sub(j, j) --char(a_t[i]:byte(j))
			end
		end
	end
end

local out_t = {}
for i = 1, #copy_a_t do
	out_t[i] = concat(copy_a_t[i], "")
end

print(concat(out_t, "\n"))
