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

lst = []

for _ in range(H):

    s = input()

    if s.find('#') >= 0:

        lst.append(s)



lst2 = []

for w in range(W):

    skip = True

    for h in range(len(lst)):

        if lst[h][w] == '#':

            skip = False

            break

    lst2.append(skip)



for x in lst:

    for idx, y in enumerate(x):

        if not lst2[idx]:

            print(y, end='')

    print()

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

lst = []

for _ in range(H):

    s = eval(input())

    if s.find('#') >= 0:

        lst.append(s)



lst2 = []

for tpl in zip(*lst):

    if '#' in tpl:

        lst2.append(tpl)



for tpl in zip(*lst2):

    print((''.join(tpl)))
H, W = map(int, input().split())
lst = []
for _ in range(H):
    s = input()
    if s.find("#") >= 0:
        lst.append(s)
lst2 = []
for w in range(W):
    skip = True
    for h in range(len(lst)):
        if lst[h][w] == "#":
            skip = False
            break
    lst2.append(skip)
for x in lst:
    for idx, y in enumerate(x):
        if not lst2[idx]:
            print(y, end="")
    print()

H, W = list(map(int, input().split()))
lst = []
for _ in range(H):
    s = eval(input())
    if s.find("#") >= 0:
        lst.append(s)
lst2 = []
for tpl in zip(*lst):
    if "#" in tpl:
        lst2.append(tpl)
for tpl in zip(*lst2):
    print(("".join(tpl)))

-H, W = map(int, input().split()) +H, W = list(map(int, input().split())) -    s = input() +    s = eval(input()) -for w in range(W): -    skip = True -    for h in range(len(lst)): -        if lst[h][w] == "#": -            skip = False -            break -    lst2.append(skip) -for x in lst: -    for idx, y in enumerate(x): -        if not lst2[idx]: -            print(y, end="") -    print() +for tpl in zip(*lst): +    if "#" in tpl: +        lst2.append(tpl) +for tpl in zip(*lst2): +    print(("".join(tpl)))