import copy

H,W=list(map(int,input().split()))

a=[eval(input()) for i in range(H)]

flag=True

while flag:

    if '.'*W in a:

        a.remove('.'*W)

        H-=1

    else:

        flag=False

b=[0]*H

f=True

while f:

    c=copy.deepcopy(a)

    g=False

    for i in range(W):# i列

        if g:

            break

        for j in range(H):

            b[j]=a[j][i]

        if ''.join(b)=='.'*H:

            for k in range(H):

                s=list(a[k])

                del s[i]

                a[k]=''.join(s)

            W-=1

            g=True

            break

    if c==a:

        f=False

for i in range(H):

    s=''.join(a[i])

    print(s)
H,W=list(map(int,input().split()))

a=[list(eval(input())) for i in range(H)]

flag=True

while flag:

    if ['.']*W in a:

        a.remove(['.']*W)

        H-=1

    else:

        flag=False

flag=True

b=[[row[i] for row in a] for i in range(W)]

while flag:

    if ['.']*H in b:

        b.remove(['.']*H)

        W-=1

    else:

        flag=False

a=[[row[i] for row in b] for i in range(H)]

for i in range(H):

    s=''.join(a[i])

    print(s)
import copy

H, W = list(map(int, input().split()))
a = [eval(input()) for i in range(H)]
flag = True
while flag:
    if "." * W in a:
        a.remove("." * W)
        H -= 1
    else:
        flag = False
b = [0] * H
f = True
while f:
    c = copy.deepcopy(a)
    g = False
    for i in range(W):  # i列
        if g:
            break
        for j in range(H):
            b[j] = a[j][i]
        if "".join(b) == "." * H:
            for k in range(H):
                s = list(a[k])
                del s[i]
                a[k] = "".join(s)
            W -= 1
            g = True
            break
    if c == a:
        f = False
for i in range(H):
    s = "".join(a[i])
    print(s)

H, W = list(map(int, input().split()))
a = [list(eval(input())) for i in range(H)]
flag = True
while flag:
    if ["."] * W in a:
        a.remove(["."] * W)
        H -= 1
    else:
        flag = False
flag = True
b = [[row[i] for row in a] for i in range(W)]
while flag:
    if ["."] * H in b:
        b.remove(["."] * H)
        W -= 1
    else:
        flag = False
a = [[row[i] for row in b] for i in range(H)]
for i in range(H):
    s = "".join(a[i])
    print(s)

-import copy - -a = [eval(input()) for i in range(H)] +a = [list(eval(input())) for i in range(H)] -    if "." * W in a: -        a.remove("." * W) +    if ["."] * W in a: +        a.remove(["."] * W) -b = [0] * H -f = True -while f: -    c = copy.deepcopy(a) -    g = False -    for i in range(W):  # i列 -        if g: -            break -        for j in range(H): -            b[j] = a[j][i] -        if "".join(b) == "." * H: -            for k in range(H): -                s = list(a[k]) -                del s[i] -                a[k] = "".join(s) -            W -= 1 -            g = True -            break -    if c == a: -        f = False +flag = True +b = [[row[i] for row in a] for i in range(W)] +while flag: +    if ["."] * H in b: +        b.remove(["."] * H) +        W -= 1 +    else: +        flag = False +a = [[row[i] for row in b] for i in range(H)]