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

a = [''] * h

for i in range(h):

	a[i] = input()

row = [False] * h

col = [False] * w

for i in range(h):

	for j in range(w):

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

			row[i] = True

			col[j] = True

for i in range(h):

	if row[i]:

		for j in range(w):

			if col[j]:

				print(a[i][j], end = '')

		print()

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

a = [[j for j in eval(input())] for i in range(h)]

b = [x for x in a if "#" in x]

c = list(zip(*[y for y in zip(*b) if "#" in y]))

for d in c:

  print(("".join(d)))
h, w = map(int, input().split())
a = [""] * h
for i in range(h):
    a[i] = input()
row = [False] * h
col = [False] * w
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            row[i] = True
            col[j] = True
for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j], end="")
        print()

h, w = list(map(int, input().split()))
a = [[j for j in eval(input())] for i in range(h)]
b = [x for x in a if "#" in x]
c = list(zip(*[y for y in zip(*b) if "#" in y]))
for d in c:
    print(("".join(d)))

-h, w = map(int, input().split()) -a = [""] * h -for i in range(h): -    a[i] = input() -row = [False] * h -col = [False] * w -for i in range(h): -    for j in range(w): -        if a[i][j] == "#": -            row[i] = True -            col[j] = True -for i in range(h): -    if row[i]: -        for j in range(w): -            if col[j]: -                print(a[i][j], end="") -        print() +h, w = list(map(int, input().split())) +a = [[j for j in eval(input())] for i in range(h)] +b = [x for x in a if "#" in x] +c = list(zip(*[y for y in zip(*b) if "#" in y])) +for d in c: +    print(("".join(d)))