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

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

import copy



tmp = copy.deepcopy(HW_list)

h_index = 0

for i, HW in enumerate(HW_list):

    is_all_shiro = True

    for hw in HW:

        if hw == '#':

            is_all_shiro = False

            h_index += 1

            break

    if is_all_shiro:

        tmp.pop(h_index)

w_index = 0

ans = copy.deepcopy(tmp)

for w in range(W):

    is_all_shiro = True

    for t in tmp:

        if t[w] == '#':

            is_all_shiro = False

            w_index += 1

            break

    if is_all_shiro:

        for a in ans:

            a.pop(w_index)

for A in ans:

    print((''.join(A)))

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

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

import copy



tate = [False] * H

yoko = [False] * W



for h in range(H):

    for w in range(W):

        if HW_list[h][w] == '#':

            tate[h] = True

            yoko[w] = True



for h in range(H):

    tmp = ''

    for w in range(W):

        if tate[h] and yoko[w]:

            tmp += HW_list[h][w]

    if tmp == '':

        continue

    print(tmp)

H, W = list(map(int, input().split()))
HW_list = [list(eval(input())) for i in range(H)]
import copy

tmp = copy.deepcopy(HW_list)
h_index = 0
for i, HW in enumerate(HW_list):
    is_all_shiro = True
    for hw in HW:
        if hw == "#":
            is_all_shiro = False
            h_index += 1
            break
    if is_all_shiro:
        tmp.pop(h_index)
w_index = 0
ans = copy.deepcopy(tmp)
for w in range(W):
    is_all_shiro = True
    for t in tmp:
        if t[w] == "#":
            is_all_shiro = False
            w_index += 1
            break
    if is_all_shiro:
        for a in ans:
            a.pop(w_index)
for A in ans:
    print(("".join(A)))

H, W = list(map(int, input().split()))
HW_list = [list(eval(input())) for i in range(H)]
import copy

tate = [False] * H
yoko = [False] * W
for h in range(H):
    for w in range(W):
        if HW_list[h][w] == "#":
            tate[h] = True
            yoko[w] = True
for h in range(H):
    tmp = ""
    for w in range(W):
        if tate[h] and yoko[w]:
            tmp += HW_list[h][w]
    if tmp == "":
        continue
    print(tmp)

-tmp = copy.deepcopy(HW_list) -h_index = 0 -for i, HW in enumerate(HW_list): -    is_all_shiro = True -    for hw in HW: -        if hw == "#": -            is_all_shiro = False -            h_index += 1 -            break -    if is_all_shiro: -        tmp.pop(h_index) -w_index = 0 -ans = copy.deepcopy(tmp) -for w in range(W): -    is_all_shiro = True -    for t in tmp: -        if t[w] == "#": -            is_all_shiro = False -            w_index += 1 -            break -    if is_all_shiro: -        for a in ans: -            a.pop(w_index) -for A in ans: -    print(("".join(A))) +tate = [False] * H +yoko = [False] * W +for h in range(H): +    for w in range(W): +        if HW_list[h][w] == "#": +            tate[h] = True +            yoko[w] = True +for h in range(H): +    tmp = "" +    for w in range(W): +        if tate[h] and yoko[w]: +            tmp += HW_list[h][w] +    if tmp == "": +        continue +    print(tmp)