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

a = []

for i in range(H):

    tmp = list(eval(input()))

    if "#" in tmp:

        a.append(tmp)



w_check = [True] * W

for i in range(len(a)):

    for j in range(W):

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

            w_check[j] = False



ans = [[] for i in range(len(a))]

for i in range(len(a)):

    for j in range(W):

        if not w_check[j]:

            ans[i].append(a[i][j])



for i in ans:

    output = ""

    for j in i:

        output += j

    print(output)

# zipを使用する版



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

a = []

for _ in range(H):

    tmp = list(eval(input()))

    if "#" in tmp:

        a.append(tmp)



a_reverse = list(map(list, list(zip(*a))))

ans = []

for tmp in a_reverse:

    if "#" in tmp:

        ans.append(tmp)



ans_list = list(map(list, list(zip(*ans))))



for tmp_list in ans_list:

    tmp = ""

    for tmp_val in tmp_list:

        tmp += tmp_val

    print(tmp)

H, W = list(map(int, input().split()))
a = []
for i in range(H):
    tmp = list(eval(input()))
    if "#" in tmp:
        a.append(tmp)
w_check = [True] * W
for i in range(len(a)):
    for j in range(W):
        if a[i][j] == "#":
            w_check[j] = False
ans = [[] for i in range(len(a))]
for i in range(len(a)):
    for j in range(W):
        if not w_check[j]:
            ans[i].append(a[i][j])
for i in ans:
    output = ""
    for j in i:
        output += j
    print(output)

# zipを使用する版
H, W = list(map(int, input().split()))
a = []
for _ in range(H):
    tmp = list(eval(input()))
    if "#" in tmp:
        a.append(tmp)
a_reverse = list(map(list, list(zip(*a))))
ans = []
for tmp in a_reverse:
    if "#" in tmp:
        ans.append(tmp)
ans_list = list(map(list, list(zip(*ans))))
for tmp_list in ans_list:
    tmp = ""
    for tmp_val in tmp_list:
        tmp += tmp_val
    print(tmp)

+# zipを使用する版 -for i in range(H): +for _ in range(H): -w_check = [True] * W -for i in range(len(a)): -    for j in range(W): -        if a[i][j] == "#": -            w_check[j] = False -ans = [[] for i in range(len(a))] -for i in range(len(a)): -    for j in range(W): -        if not w_check[j]: -            ans[i].append(a[i][j]) -for i in ans: -    output = "" -    for j in i: -        output += j -    print(output) +a_reverse = list(map(list, list(zip(*a)))) +ans = [] +for tmp in a_reverse: +    if "#" in tmp: +        ans.append(tmp) +ans_list = list(map(list, list(zip(*ans)))) +for tmp_list in ans_list: +    tmp = "" +    for tmp_val in tmp_list: +        tmp += tmp_val +    print(tmp)