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

a=[]

for i in range(H):

    ai=input()

    if ai=="."*W:

        continue

    a.append(ai)

h=len(a)

def tenti(a):

    b=[]

    h=len(a)

    w=len(a[0])

    for i in range(w):

        bi=[]

        for j in range(h):

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

        b.append(bi)

    return b

b=tenti(a)

h=len(b)

w=len(b[0])

c=[]

for i in range(h):

    if b[i]==["."]*w:

        continue

    c.append(b[i])

d=tenti(c)

for i in range(len(d)):

    for j in range(len(d[0])):

        if j==len(d[0])-1:

            print(d[i][j])

            break

        print(d[i][j],end="")

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

c=[]

for i in range(H):

  ci=eval(input())

  if ci=="."*W:

    continue

  c.append(ci+"#")

l=len(c)

k=[True]*(W+1)

for i in range(l):

  for j in range(W,-1,-1):

    k[j]=k[j] and (c[i][j]==".")



for i in range(l):

  for j in range(W,-1,-1):

    if k[j]:

      c[i]=c[i][0:j]+c[i][j+1:]

for i in range(l):

  print((c[i][:-1]))
H, W = map(int, input().split())
a = []
for i in range(H):
    ai = input()
    if ai == "." * W:
        continue
    a.append(ai)
h = len(a)


def tenti(a):
    b = []
    h = len(a)
    w = len(a[0])
    for i in range(w):
        bi = []
        for j in range(h):
            bi.append(a[j][i])
        b.append(bi)
    return b


b = tenti(a)
h = len(b)
w = len(b[0])
c = []
for i in range(h):
    if b[i] == ["."] * w:
        continue
    c.append(b[i])
d = tenti(c)
for i in range(len(d)):
    for j in range(len(d[0])):
        if j == len(d[0]) - 1:
            print(d[i][j])
            break
        print(d[i][j], end="")

H, W = list(map(int, input().split()))
c = []
for i in range(H):
    ci = eval(input())
    if ci == "." * W:
        continue
    c.append(ci + "#")
l = len(c)
k = [True] * (W + 1)
for i in range(l):
    for j in range(W, -1, -1):
        k[j] = k[j] and (c[i][j] == ".")
for i in range(l):
    for j in range(W, -1, -1):
        if k[j]:
            c[i] = c[i][0:j] + c[i][j + 1 :]
for i in range(l):
    print((c[i][:-1]))

-H, W = map(int, input().split()) -a = [] +H, W = list(map(int, input().split())) +c = [] -    ai = input() -    if ai == "." * W: +    ci = eval(input()) +    if ci == "." * W: -    a.append(ai) -h = len(a) - - -def tenti(a): -    b = [] -    h = len(a) -    w = len(a[0]) -    for i in range(w): -        bi = [] -        for j in range(h): -            bi.append(a[j][i]) -        b.append(bi) -    return b - - -b = tenti(a) -h = len(b) -w = len(b[0]) -c = [] -for i in range(h): -    if b[i] == ["."] * w: -        continue -    c.append(b[i]) -d = tenti(c) -for i in range(len(d)): -    for j in range(len(d[0])): -        if j == len(d[0]) - 1: -            print(d[i][j]) -            break -        print(d[i][j], end="") +    c.append(ci + "#") +l = len(c) +k = [True] * (W + 1) +for i in range(l): +    for j in range(W, -1, -1): +        k[j] = k[j] and (c[i][j] == ".") +for i in range(l): +    for j in range(W, -1, -1): +        if k[j]: +            c[i] = c[i][0:j] + c[i][j + 1 :] +for i in range(l): +    print((c[i][:-1]))