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

A = [input() for i in range(h)]

AnsH=[]

for i in range(h):

    if "#" in A[i]:

        AnsH.append(i)

AnsW=[]

for i in range(w):

    c = 0

    for j in range(h):

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

            c = 1

    if c == 1:

        AnsW.append(i)

for i in AnsH:

    for j in AnsW:

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



    print()

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

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

AH = []

AW = []

for i in range(h):

    if '#' in A[i]:

        AH.append(i)

for j in range(w):

    flag = 0

    for i in range(h):

        if A[i][j]=='#':

            flag = 1

    if flag:

        AW.append(j)

for i in AH:

    res = []

    for j in AW:

        res.append(A[i][j])

    print(("".join(res)))
h, w = map(int, input().split())
A = [input() for i in range(h)]
AnsH = []
for i in range(h):
    if "#" in A[i]:
        AnsH.append(i)
AnsW = []
for i in range(w):
    c = 0
    for j in range(h):
        if A[j][i] == "#":
            c = 1
    if c == 1:
        AnsW.append(i)
for i in AnsH:
    for j in AnsW:
        print(A[i][j], end="")
    print()

h, w = list(map(int, input().split()))
A = [list(eval(input())) for i in range(h)]
AH = []
AW = []
for i in range(h):
    if "#" in A[i]:
        AH.append(i)
for j in range(w):
    flag = 0
    for i in range(h):
        if A[i][j] == "#":
            flag = 1
    if flag:
        AW.append(j)
for i in AH:
    res = []
    for j in AW:
        res.append(A[i][j])
    print(("".join(res)))

-h, w = map(int, input().split()) -A = [input() for i in range(h)] -AnsH = [] +h, w = list(map(int, input().split())) +A = [list(eval(input())) for i in range(h)] +AH = [] +AW = [] -        AnsH.append(i) -AnsW = [] -for i in range(w): -    c = 0 -    for j in range(h): -        if A[j][i] == "#": -            c = 1 -    if c == 1: -        AnsW.append(i) -for i in AnsH: -    for j in AnsW: -        print(A[i][j], end="") -    print() +        AH.append(i) +for j in range(w): +    flag = 0 +    for i in range(h): +        if A[i][j] == "#": +            flag = 1 +    if flag: +        AW.append(j) +for i in AH: +    res = [] +    for j in AW: +        res.append(A[i][j]) +    print(("".join(res)))