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

A=[]

for _ in range(H):

    a=list(eval(input()))

    if("#" in a):

        A.append(a)

answer=[]

for i in range(W):

    tmp=[]

    hantei=True

    for a in A:

        if(a[i]=="#"):

            hantei=False

        tmp.append(a[i])

    if(hantei==False):

        answer.append(tmp)



result = list(zip(*answer))

for r in result:

    print(("".join(r)))
H, W = list(map(int, input().split()))

A = []

answer = []

for _ in range(H):

    a = list(eval(input()))

    if("#" in a): A.append(a)





for a in list(zip(*A)):

    if("#" in a): answer.append(a)



for result in list(zip(*answer)): print(("".join(result)))
H, W = list(map(int, input().split()))
A = []
for _ in range(H):
    a = list(eval(input()))
    if "#" in a:
        A.append(a)
answer = []
for i in range(W):
    tmp = []
    hantei = True
    for a in A:
        if a[i] == "#":
            hantei = False
        tmp.append(a[i])
    if hantei == False:
        answer.append(tmp)
result = list(zip(*answer))
for r in result:
    print(("".join(r)))

H, W = list(map(int, input().split()))
A = []
answer = []
for _ in range(H):
    a = list(eval(input()))
    if "#" in a:
        A.append(a)
for a in list(zip(*A)):
    if "#" in a:
        answer.append(a)
for result in list(zip(*answer)):
    print(("".join(result)))

+answer = [] -answer = [] -for i in range(W): -    tmp = [] -    hantei = True -    for a in A: -        if a[i] == "#": -            hantei = False -        tmp.append(a[i]) -    if hantei == False: -        answer.append(tmp) -result = list(zip(*answer)) -for r in result: -    print(("".join(r))) +for a in list(zip(*A)): +    if "#" in a: +        answer.append(a) +for result in list(zip(*answer)): +    print(("".join(result)))