h,w,_=io.read("*n","*n","*l")
a,b={},{}
s={}
for i=1,h do
	s[i]=io.read("*l")
end
for i=1,h do
	a[i]=false
	for j=1,w do
		if s[i]:sub(j,j)=='#' then a[i]=true end
	end
end

for i=1,w do
	b[i]=false
	for j=1,h do
		if s[j]:sub(i,i)=='#' then b[i]=true end
	end
end

for i=1,h do
	for j=1,w do
		if a[i] and b[j] then
			io.write(s[i]:sub(j,j))
		end
	end
	if a[i] then io.write("\n")end
end