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



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

result = a_list[:]

for i,aa in enumerate(a_list):

    if aa.count('.') == len(aa):

        result[i] = 1

result = [r for r in result if r != 1]



#print(result)

import numpy as np

T_result = np.array(result).T

result2 = T_result.tolist()

for i, aa in enumerate(result2):

    if aa.count('.') == len(aa):

        result2[i] = 1



result2 = [r for r in result2 if r != 1]

for r2 in np.array(result2).T.tolist():

    print((''.join(r2)))
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()))
a_list = [list(eval(input())) for i in range(H)]
result = a_list[:]
for i, aa in enumerate(a_list):
    if aa.count(".") == len(aa):
        result[i] = 1
result = [r for r in result if r != 1]
# print(result)
import numpy as np

T_result = np.array(result).T
result2 = T_result.tolist()
for i, aa in enumerate(result2):
    if aa.count(".") == len(aa):
        result2[i] = 1
result2 = [r for r in result2 if r != 1]
for r2 in np.array(result2).T.tolist():
    print(("".join(r2)))

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)))

-a_list = [list(eval(input())) for i in range(H)] -result = a_list[:] -for i, aa in enumerate(a_list): -    if aa.count(".") == len(aa): -        result[i] = 1 -result = [r for r in result if r != 1] -# print(result) -import numpy as np +HW_list = [list(eval(input())) for i in range(H)] +import copy -T_result = np.array(result).T -result2 = T_result.tolist() -for i, aa in enumerate(result2): -    if aa.count(".") == len(aa): -        result2[i] = 1 -result2 = [r for r in result2 if r != 1] -for r2 in np.array(result2).T.tolist(): -    print(("".join(r2))) +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)))