# coding: utf-8

import fractions

#N = int(input())



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

h_list = []

w_list = []

F = []

for i in range(h):

    l = list(eval(input()))

    F.append(l)

    if list(set(l)) == ['.']:

        w_list.append(i)

        

for i in range(w):

    cnt = 0

    for j in range(h):

        if F[j][i] == '.':

            cnt += 1

        else:

            break

    if cnt == h:

        h_list.append(i)

A = []

#print(h_list,w_list)#ここまでOK

for i in range(h):

    if i not in w_list:

        l = []

        for j in range(w):

            if j not in h_list:

                #print(F[i][j])

                l.append(F[i][j])

        

        A.append(l)



for i in range(len(A)):

    print((''.join(A[i])))
# coding: utf-8



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

A = []



for i in range(h):

    l = list(eval(input()))

    if list(set(l)) == ['.']:

        h -= 1

    else:

        A.append(l)

#for a in A:

    #print(a)

Ans = []

for i in range(w):

    cnt = 0

    for j in range(h):

        if A[j][i] == '.':

            cnt += 1

    if cnt == h:

        Ans.append(i)



for i in Ans:

    for j in range(h):

        A[j][i] = ''



for a in A:

    print((''.join(a)))
# coding: utf-8
import fractions

# N = int(input())
h, w = list(map(int, input().split()))
h_list = []
w_list = []
F = []
for i in range(h):
    l = list(eval(input()))
    F.append(l)
    if list(set(l)) == ["."]:
        w_list.append(i)
for i in range(w):
    cnt = 0
    for j in range(h):
        if F[j][i] == ".":
            cnt += 1
        else:
            break
    if cnt == h:
        h_list.append(i)
A = []
# print(h_list,w_list)#ここまでOK
for i in range(h):
    if i not in w_list:
        l = []
        for j in range(w):
            if j not in h_list:
                # print(F[i][j])
                l.append(F[i][j])
        A.append(l)
for i in range(len(A)):
    print(("".join(A[i])))

# coding: utf-8
h, w = list(map(int, input().split()))
A = []
for i in range(h):
    l = list(eval(input()))
    if list(set(l)) == ["."]:
        h -= 1
    else:
        A.append(l)
# for a in A:
# print(a)
Ans = []
for i in range(w):
    cnt = 0
    for j in range(h):
        if A[j][i] == ".":
            cnt += 1
    if cnt == h:
        Ans.append(i)
for i in Ans:
    for j in range(h):
        A[j][i] = ""
for a in A:
    print(("".join(a)))

-import fractions - -# N = int(input()) -h_list = [] -w_list = [] -F = [] +A = [] -    F.append(l) -        w_list.append(i) +        h -= 1 +    else: +        A.append(l) +# for a in A: +# print(a) +Ans = [] -        if F[j][i] == ".": +        if A[j][i] == ".": -        else: -            break -        h_list.append(i) -A = [] -# print(h_list,w_list)#ここまでOK -for i in range(h): -    if i not in w_list: -        l = [] -        for j in range(w): -            if j not in h_list: -                # print(F[i][j]) -                l.append(F[i][j]) -        A.append(l) -for i in range(len(A)): -    print(("".join(A[i]))) +        Ans.append(i) +for i in Ans: +    for j in range(h): +        A[j][i] = "" +for a in A: +    print(("".join(a)))