h,w=map(int,input().split())

M=list(input() for _ in range(h))

c=[]

for i in range(h):

    if "#" not in M[i]:

        c.append(i)

for dot in c[::-1]:

    M.pop(dot)



c=[]

col=[]

for i in range(len(M[0])):

    flag=1

    for j in range(len(M)):

        if "#" in M[j][i]:flag=0

    if flag==1:c.append(i)



for i in c[::-1]:

    for row in M:

        list(row).pop(i)

for i in range(len(M)):

    flag=0

    for j in range(len(M[0])):

        if j not in c:

            print(*M[i][j],end="")

            flag=1

    if i<len(M)-1 and flag==1:print()    

h, w = list(map(int,input().split()))

a = [eval(input()) for _ in range(h)]

c = 0



#行の中で「....」があれば取り除く.

while "."*w in a:

    a.remove("."*w) #removeは該当要素のうち最初の要素を削除

    c += 1

    

#行と列の入れ替え

a = ["".join(column) for column in zip(*a)]

while "."*(h-c) in a:

    a.remove("."*(h-c))



#行と列を再度入れ替えて出力.

for row in zip(*a):

    print(("".join(row)))
h, w = map(int, input().split())
M = list(input() for _ in range(h))
c = []
for i in range(h):
    if "#" not in M[i]:
        c.append(i)
for dot in c[::-1]:
    M.pop(dot)
c = []
col = []
for i in range(len(M[0])):
    flag = 1
    for j in range(len(M)):
        if "#" in M[j][i]:
            flag = 0
    if flag == 1:
        c.append(i)
for i in c[::-1]:
    for row in M:
        list(row).pop(i)
for i in range(len(M)):
    flag = 0
    for j in range(len(M[0])):
        if j not in c:
            print(*M[i][j], end="")
            flag = 1
    if i < len(M) - 1 and flag == 1:
        print()

h, w = list(map(int, input().split()))
a = [eval(input()) for _ in range(h)]
c = 0
# 行の中で「....」があれば取り除く.
while "." * w in a:
    a.remove("." * w)  # removeは該当要素のうち最初の要素を削除
    c += 1
# 行と列の入れ替え
a = ["".join(column) for column in zip(*a)]
while "." * (h - c) in a:
    a.remove("." * (h - c))
# 行と列を再度入れ替えて出力.
for row in zip(*a):
    print(("".join(row)))

-h, w = map(int, input().split()) -M = list(input() for _ in range(h)) -c = [] -for i in range(h): -    if "#" not in M[i]: -        c.append(i) -for dot in c[::-1]: -    M.pop(dot) -c = [] -col = [] -for i in range(len(M[0])): -    flag = 1 -    for j in range(len(M)): -        if "#" in M[j][i]: -            flag = 0 -    if flag == 1: -        c.append(i) -for i in c[::-1]: -    for row in M: -        list(row).pop(i) -for i in range(len(M)): -    flag = 0 -    for j in range(len(M[0])): -        if j not in c: -            print(*M[i][j], end="") -            flag = 1 -    if i < len(M) - 1 and flag == 1: -        print() +h, w = list(map(int, input().split())) +a = [eval(input()) for _ in range(h)] +c = 0 +# 行の中で「....」があれば取り除く. +while "." * w in a: +    a.remove("." * w)  # removeは該当要素のうち最初の要素を削除 +    c += 1 +# 行と列の入れ替え +a = ["".join(column) for column in zip(*a)] +while "." * (h - c) in a: +    a.remove("." * (h - c)) +# 行と列を再度入れ替えて出力. +for row in zip(*a): +    print(("".join(row)))