from numpy import*

h,w=int8(input().split())

a=array(eval('list(input()),'*h))

print((*list(map(''.join,a[any(a<'.',1)][:,any(a<'.',0)]))))
f=lambda s:list(zip(*[t for t in s if'#'in t]));print((*list(map(''.join,f(f(open(0)))))))
from numpy import *

h, w = int8(input().split())
a = array(eval("list(input())," * h))
print((*list(map("".join, a[any(a < ".", 1)][:, any(a < ".", 0)]))))

f = lambda s: list(zip(*[t for t in s if "#" in t]))
print((*list(map("".join, f(f(open(0)))))))

-from numpy import * - -h, w = int8(input().split()) -a = array(eval("list(input())," * h)) -print((*list(map("".join, a[any(a < ".", 1)][:, any(a < ".", 0)])))) +f = lambda s: list(zip(*[t for t in s if "#" in t])) +print((*list(map("".join, f(f(open(0)))))))