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

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



hl = []

wl = []

for h in range(H):

    if sum([0 if i == "." else 1 for i in A[h]]) > 0:

        hl.append(h)



for w in range(W):

    if sum([0 if A[i][w] == "." else 1 for i in range(H)]) > 0:

        wl.append(w)



for h in hl:

    line = []

    for w in wl:

        line.append(A[h][w])

    print(*line, sep="")

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

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

resH = [True] * H

resW = [True] * W



for h in range(H):

    judge = False

    for w in range(W):

        if a[h][w] == "#":

            judge = True

    resH[h] = judge



for w in range(W):

    judge = False

    for h in range(H):

        if a[h][w] == "#":

            judge = True

    resW[w] = judge



for h, row in enumerate(a):

    tmp = []

    for w, element in enumerate(row):

        if resH[h] and resW[w]:

            tmp.append(element)

    if tmp:

        print(*tmp, sep="")

H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]
hl = []
wl = []
for h in range(H):
    if sum([0 if i == "." else 1 for i in A[h]]) > 0:
        hl.append(h)
for w in range(W):
    if sum([0 if A[i][w] == "." else 1 for i in range(H)]) > 0:
        wl.append(w)
for h in hl:
    line = []
    for w in wl:
        line.append(A[h][w])
    print(*line, sep="")

H, W = map(int, input().split())
a = [list(input()) for _ in range(H)]
resH = [True] * H
resW = [True] * W
for h in range(H):
    judge = False
    for w in range(W):
        if a[h][w] == "#":
            judge = True
    resH[h] = judge
for w in range(W):
    judge = False
    for h in range(H):
        if a[h][w] == "#":
            judge = True
    resW[w] = judge
for h, row in enumerate(a):
    tmp = []
    for w, element in enumerate(row):
        if resH[h] and resW[w]:
            tmp.append(element)
    if tmp:
        print(*tmp, sep="")

-A = [list(input()) for _ in range(H)] -hl = [] -wl = [] +a = [list(input()) for _ in range(H)] +resH = [True] * H +resW = [True] * W -    if sum([0 if i == "." else 1 for i in A[h]]) > 0: -        hl.append(h) +    judge = False +    for w in range(W): +        if a[h][w] == "#": +            judge = True +    resH[h] = judge -    if sum([0 if A[i][w] == "." else 1 for i in range(H)]) > 0: -        wl.append(w) -for h in hl: -    line = [] -    for w in wl: -        line.append(A[h][w]) -    print(*line, sep="") +    judge = False +    for h in range(H): +        if a[h][w] == "#": +            judge = True +    resW[w] = judge +for h, row in enumerate(a): +    tmp = [] +    for w, element in enumerate(row): +        if resH[h] and resW[w]: +            tmp.append(element) +    if tmp: +        print(*tmp, sep="")