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

A = [eval(input()) for _ in range(H)]



h_check = [0] * H

w_check = [0] * W



for i in range(H):

  flag = 0

  for j in range(W):

    if A[i][j] != ".":

      flag = 1

      break

  h_check[i] = flag



for j in range(W):

  flag = 0

  for i in range(H):

    if A[i][j] != ".":

      flag = 1

      break

  w_check[j] = flag



for i in range(H):

  if h_check[i]:

    tmp = ""

    for j in range(W):

      if w_check[j]:

        tmp += A[i][j]

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

A = [eval(input()) for _ in range(H)]



h_check = [0] * H

w_check = [0] * W



for i in range(H):

  for j in range(W):

    if A[i][j] == ".":

      h_check[i] += 1

      w_check[j] += 1



h_check = list([1 - x // W for x in h_check])

w_check = list([1 - x // H for x in w_check])



for i in range(H):

  if h_check[i]:

    tmp = ""

    for j in range(W):

      if w_check[j]:

        tmp += A[i][j]

    print(tmp)
H, W = list(map(int, input().split()))
A = [eval(input()) for _ in range(H)]
h_check = [0] * H
w_check = [0] * W
for i in range(H):
    flag = 0
    for j in range(W):
        if A[i][j] != ".":
            flag = 1
            break
    h_check[i] = flag
for j in range(W):
    flag = 0
    for i in range(H):
        if A[i][j] != ".":
            flag = 1
            break
    w_check[j] = flag
for i in range(H):
    if h_check[i]:
        tmp = ""
        for j in range(W):
            if w_check[j]:
                tmp += A[i][j]
        print(tmp)

H, W = list(map(int, input().split()))
A = [eval(input()) for _ in range(H)]
h_check = [0] * H
w_check = [0] * W
for i in range(H):
    for j in range(W):
        if A[i][j] == ".":
            h_check[i] += 1
            w_check[j] += 1
h_check = list([1 - x // W for x in h_check])
w_check = list([1 - x // H for x in w_check])
for i in range(H):
    if h_check[i]:
        tmp = ""
        for j in range(W):
            if w_check[j]:
                tmp += A[i][j]
        print(tmp)

-    flag = 0 -        if A[i][j] != ".": -            flag = 1 -            break -    h_check[i] = flag -for j in range(W): -    flag = 0 -    for i in range(H): -        if A[i][j] != ".": -            flag = 1 -            break -    w_check[j] = flag +        if A[i][j] == ".": +            h_check[i] += 1 +            w_check[j] += 1 +h_check = list([1 - x // W for x in h_check]) +w_check = list([1 - x // H for x in w_check])