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

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

for i in range(h):

    if '#' not in a[i]:

        a[i]=['n']*w

for i in range(w):

    l=[a[j][i] for j in range(len(a))]

    if '#' not in l:

        for k in range(len(a)):

           a[k][i]='n'

for i in a:

    l=[x for x in i if x!='n']

    if l:

        print((''.join(l)))
h,w=list(map(int,input().split()))

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



l1=[]

for i in a:

    if '#' in i:

        l1.append(i)

l2=[]

for i in zip(*l1):

    if '#' in i:

        l2.append(i)

l3=list(zip(*l2))

for i in l3:

    print((''.join(i)))
h, w = list(map(int, input().split()))
a = [list(eval(input())) for i in range(h)]
for i in range(h):
    if "#" not in a[i]:
        a[i] = ["n"] * w
for i in range(w):
    l = [a[j][i] for j in range(len(a))]
    if "#" not in l:
        for k in range(len(a)):
            a[k][i] = "n"
for i in a:
    l = [x for x in i if x != "n"]
    if l:
        print(("".join(l)))

h, w = list(map(int, input().split()))
a = [list(eval(input())) for i in range(h)]
l1 = []
for i in a:
    if "#" in i:
        l1.append(i)
l2 = []
for i in zip(*l1):
    if "#" in i:
        l2.append(i)
l3 = list(zip(*l2))
for i in l3:
    print(("".join(i)))

-for i in range(h): -    if "#" not in a[i]: -        a[i] = ["n"] * w -for i in range(w): -    l = [a[j][i] for j in range(len(a))] -    if "#" not in l: -        for k in range(len(a)): -            a[k][i] = "n" +l1 = [] -    l = [x for x in i if x != "n"] -    if l: -        print(("".join(l))) +    if "#" in i: +        l1.append(i) +l2 = [] +for i in zip(*l1): +    if "#" in i: +        l2.append(i) +l3 = list(zip(*l2)) +for i in l3: +    print(("".join(i)))