import numpy as np



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

a = []

for i in range(H):

	_a = list(input())

	a.append(_a)

a = np.array(a)

b = a.copy()

while True:

	r_exist = False

	c_exist = False

	for i in range(len(a)):

		if not '#' in a[i, :]:

			b = np.delete(a, i, 0)

			r_exist = True

	a = b.copy()

	for i in range(len(b[0])):

		if not '#' in b[:, i]:

			a = np.delete(b, i, 1)

			c_exist = True

	b = a.copy()

	if not (r_exist or c_exist):

		break

for i in b:

	print(('').join(i))

import numpy as np

import sys



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

a = []

for i in range(H):

	_a = list(input())

	a.append(_a)

a = np.array(a)



row_exist = [False] * H

col_exist = [False] * W

for i in range(H):

	if '#' in a[i, :]:

		row_exist[i] = True

for i in range(W):

	if '#' in a[:, i]:

		col_exist[i] = True

for i in range(H):

	for j in range(W):

		if row_exist[i] and col_exist[j]:

			sys.stdout.write(a[i, j])

	if row_exist[i]:

		print("")

import numpy as np

H, W = list(map(int, input().split()))
a = []
for i in range(H):
    _a = list(input())
    a.append(_a)
a = np.array(a)
b = a.copy()
while True:
    r_exist = False
    c_exist = False
    for i in range(len(a)):
        if not "#" in a[i, :]:
            b = np.delete(a, i, 0)
            r_exist = True
    a = b.copy()
    for i in range(len(b[0])):
        if not "#" in b[:, i]:
            a = np.delete(b, i, 1)
            c_exist = True
    b = a.copy()
    if not (r_exist or c_exist):
        break
for i in b:
    print(("").join(i))

import numpy as np
import sys

H, W = list(map(int, input().split()))
a = []
for i in range(H):
    _a = list(input())
    a.append(_a)
a = np.array(a)
row_exist = [False] * H
col_exist = [False] * W
for i in range(H):
    if "#" in a[i, :]:
        row_exist[i] = True
for i in range(W):
    if "#" in a[:, i]:
        col_exist[i] = True
for i in range(H):
    for j in range(W):
        if row_exist[i] and col_exist[j]:
            sys.stdout.write(a[i, j])
    if row_exist[i]:
        print("")

+import sys -b = a.copy() -while True: -    r_exist = False -    c_exist = False -    for i in range(len(a)): -        if not "#" in a[i, :]: -            b = np.delete(a, i, 0) -            r_exist = True -    a = b.copy() -    for i in range(len(b[0])): -        if not "#" in b[:, i]: -            a = np.delete(b, i, 1) -            c_exist = True -    b = a.copy() -    if not (r_exist or c_exist): -        break -for i in b: -    print(("").join(i)) +row_exist = [False] * H +col_exist = [False] * W +for i in range(H): +    if "#" in a[i, :]: +        row_exist[i] = True +for i in range(W): +    if "#" in a[:, i]: +        col_exist[i] = True +for i in range(H): +    for j in range(W): +        if row_exist[i] and col_exist[j]: +            sys.stdout.write(a[i, j]) +    if row_exist[i]: +        print("")