from copy import deepcopy

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

alist = [list(eval(input())) for _ in range(H)]

acopy = deepcopy(alist)

counter = 0

for i in range(W):

    for a in alist:

        if a[i] == "#":

            break

    else:

        for a in acopy:

            a.pop(i - counter)

        counter += 1



for a in acopy:

    if "#" in a:

        print(("".join(a)))

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

graph = [list(eval(input())) for _ in range(H)]

flg = True

while flg:

    loop = False

    for i in range(len(graph)):

        if "#" not in graph[i]:

            graph.pop(i)

            loop = True

            break

    if loop:

        continue

    for j in range(len(graph[0])):

        tate = [line[j] for line in graph]

        if "#" not in tate:

            for i in range(len(graph)):

                graph[i].pop(j)

            break

    else:

        flg = False

for line in graph:

    print(("".join(line)))

from copy import deepcopy

H, W = list(map(int, input().split()))
alist = [list(eval(input())) for _ in range(H)]
acopy = deepcopy(alist)
counter = 0
for i in range(W):
    for a in alist:
        if a[i] == "#":
            break
    else:
        for a in acopy:
            a.pop(i - counter)
        counter += 1
for a in acopy:
    if "#" in a:
        print(("".join(a)))

H, W = list(map(int, input().split()))
graph = [list(eval(input())) for _ in range(H)]
flg = True
while flg:
    loop = False
    for i in range(len(graph)):
        if "#" not in graph[i]:
            graph.pop(i)
            loop = True
            break
    if loop:
        continue
    for j in range(len(graph[0])):
        tate = [line[j] for line in graph]
        if "#" not in tate:
            for i in range(len(graph)):
                graph[i].pop(j)
            break
    else:
        flg = False
for line in graph:
    print(("".join(line)))

-from copy import deepcopy - -alist = [list(eval(input())) for _ in range(H)] -acopy = deepcopy(alist) -counter = 0 -for i in range(W): -    for a in alist: -        if a[i] == "#": +graph = [list(eval(input())) for _ in range(H)] +flg = True +while flg: +    loop = False +    for i in range(len(graph)): +        if "#" not in graph[i]: +            graph.pop(i) +            loop = True +            break +    if loop: +        continue +    for j in range(len(graph[0])): +        tate = [line[j] for line in graph] +        if "#" not in tate: +            for i in range(len(graph)): +                graph[i].pop(j) -        for a in acopy: -            a.pop(i - counter) -        counter += 1 -for a in acopy: -    if "#" in a: -        print(("".join(a))) +        flg = False +for line in graph: +    print(("".join(line)))