f=lambda s:zip(*[t for t in s if'#'in t])

for r in f(f(open(0).readlines())):print(*r,sep='')

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

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

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