na = lambda: list(map(int, input().split()))



h, w = na()

t = []

cnt = 0

for i in range(h):

    I = list(input())

    if not("#" in I):

        cnt += 1

        continue

    t.append(I)

output = []

for j in range(w):

    flag = False

    for i in range(h-cnt):

        if t[i][j] == "#":

            flag = True

    if flag:

        output.append(j)

for T in t:

    for num, i in enumerate(T):

        if num in output:

            print(i, end="")

    print()

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

t = []

goodx = [0]*110

goody = [0]*110



for i in range(h):

    t.append(input())



for i in range(h):

    for j in range(w):

        if t[i][j] == "#":

            goodx[i] = 1

            goody[j] = 1



for i in range(h):

    if goodx[i]:

        for j in range(w):

            if goody[j]:

                print(t[i][j], end="")

        print()

na = lambda: list(map(int, input().split()))
h, w = na()
t = []
cnt = 0
for i in range(h):
    I = list(input())
    if not ("#" in I):
        cnt += 1
        continue
    t.append(I)
output = []
for j in range(w):
    flag = False
    for i in range(h - cnt):
        if t[i][j] == "#":
            flag = True
    if flag:
        output.append(j)
for T in t:
    for num, i in enumerate(T):
        if num in output:
            print(i, end="")
    print()

h, w = map(int, input().split())
t = []
goodx = [0] * 110
goody = [0] * 110
for i in range(h):
    t.append(input())
for i in range(h):
    for j in range(w):
        if t[i][j] == "#":
            goodx[i] = 1
            goody[j] = 1
for i in range(h):
    if goodx[i]:
        for j in range(w):
            if goody[j]:
                print(t[i][j], end="")
        print()

-na = lambda: list(map(int, input().split())) -h, w = na() +h, w = map(int, input().split()) -cnt = 0 +goodx = [0] * 110 +goody = [0] * 110 -    I = list(input()) -    if not ("#" in I): -        cnt += 1 -        continue -    t.append(I) -output = [] -for j in range(w): -    flag = False -    for i in range(h - cnt): +    t.append(input()) +for i in range(h): +    for j in range(w): -            flag = True -    if flag: -        output.append(j) -for T in t: -    for num, i in enumerate(T): -        if num in output: -            print(i, end="") -    print() +            goodx[i] = 1 +            goody[j] = 1 +for i in range(h): +    if goodx[i]: +        for j in range(w): +            if goody[j]: +                print(t[i][j], end="") +        print()