import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

sys.setrecursionlimit(10 ** 7)



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

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

ans = []

memo_x = []

memo_y = []

for i in range(h):

    cnt = 0

    for j in range(w):

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

            cnt += 1

    if cnt == w:

        memo_x.append(i)

for i in range(w):

    cnt = 0

    for j in range(h):

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

            cnt += 1

    if cnt == h:

        memo_y.append(i)

for i in range(h):

    if i not in memo_x:

        b = ''

        for j in range(w):

            if j not in memo_y:

                b += a[i][j]

        ans.append(b)

for i in range(len(ans)):

    print((ans[i]))

import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

sys.setrecursionlimit(10 ** 7)



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

a = [readline().rstrip().decode() for i in range(h)]

memo_w = [False] * h

memo_h = [False] * w

for i in range(h):

    flag = True

    for j in range(w):

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

            flag = False

            break

    if flag:

        memo_w[i] = True

for i in range(w):

    flag = True

    for j in range(h):

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

            flag = False

            break

    if flag:

        memo_h[i] = True

for i in range(h):

    if not memo_w[i]:

        ans = ''

        for j in range(w):

            if not memo_h[j]:

                ans += a[i][j]

        print(ans)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
h, w = list(map(int, readline().split()))
a = [eval(input()) for i in range(h)]
ans = []
memo_x = []
memo_y = []
for i in range(h):
    cnt = 0
    for j in range(w):
        if a[i][j] == ".":
            cnt += 1
    if cnt == w:
        memo_x.append(i)
for i in range(w):
    cnt = 0
    for j in range(h):
        if a[j][i] == ".":
            cnt += 1
    if cnt == h:
        memo_y.append(i)
for i in range(h):
    if i not in memo_x:
        b = ""
        for j in range(w):
            if j not in memo_y:
                b += a[i][j]
        ans.append(b)
for i in range(len(ans)):
    print((ans[i]))

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**7)
h, w = list(map(int, readline().split()))
a = [readline().rstrip().decode() for i in range(h)]
memo_w = [False] * h
memo_h = [False] * w
for i in range(h):
    flag = True
    for j in range(w):
        if a[i][j] == "#":
            flag = False
            break
    if flag:
        memo_w[i] = True
for i in range(w):
    flag = True
    for j in range(h):
        if a[j][i] == "#":
            flag = False
            break
    if flag:
        memo_h[i] = True
for i in range(h):
    if not memo_w[i]:
        ans = ""
        for j in range(w):
            if not memo_h[j]:
                ans += a[i][j]
        print(ans)

-a = [eval(input()) for i in range(h)] -ans = [] -memo_x = [] -memo_y = [] +a = [readline().rstrip().decode() for i in range(h)] +memo_w = [False] * h +memo_h = [False] * w -    cnt = 0 +    flag = True -        if a[i][j] == ".": -            cnt += 1 -    if cnt == w: -        memo_x.append(i) +        if a[i][j] == "#": +            flag = False +            break +    if flag: +        memo_w[i] = True -    cnt = 0 +    flag = True -        if a[j][i] == ".": -            cnt += 1 -    if cnt == h: -        memo_y.append(i) +        if a[j][i] == "#": +            flag = False +            break +    if flag: +        memo_h[i] = True -    if i not in memo_x: -        b = "" +    if not memo_w[i]: +        ans = "" -            if j not in memo_y: -                b += a[i][j] -        ans.append(b) -for i in range(len(ans)): -    print((ans[i])) +            if not memo_h[j]: +                ans += a[i][j] +        print(ans)