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

L = []

brank = "." * W

ban = []

for _ in range(H):

  s = eval(input())

  if brank == s:

    continue

  L.append(list(map(str, s)))

  

for i in range(W):

  for l in L:

    if l[i] != ".":

      break

  else:

    ban.append(i)

    continue



for l in L:

  ans = ""

  for i in range(W):

    if i in ban:

      continue

    ans += l[i]

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

L = []

brank = "." * W

for _ in range(H):

  S = eval(input())

  if S == brank:

    continue

  L.append(list(map(str, S)))



if L:

  L1 = list(zip(*L))

  brank = tuple(["." for _ in range(len(L1[0]))])

  ans = []



  for l in L1:

    if l == brank:

      continue

    ans.append(l)





  for a in zip(*ans):

    print(("".join(a)))
H, W = list(map(int, input().split()))
L = []
brank = "." * W
ban = []
for _ in range(H):
    s = eval(input())
    if brank == s:
        continue
    L.append(list(map(str, s)))
for i in range(W):
    for l in L:
        if l[i] != ".":
            break
    else:
        ban.append(i)
        continue
for l in L:
    ans = ""
    for i in range(W):
        if i in ban:
            continue
        ans += l[i]
    print(ans)

H, W = list(map(int, input().split()))
L = []
brank = "." * W
for _ in range(H):
    S = eval(input())
    if S == brank:
        continue
    L.append(list(map(str, S)))
if L:
    L1 = list(zip(*L))
    brank = tuple(["." for _ in range(len(L1[0]))])
    ans = []
    for l in L1:
        if l == brank:
            continue
        ans.append(l)
    for a in zip(*ans):
        print(("".join(a)))

-ban = [] -    s = eval(input()) -    if brank == s: +    S = eval(input()) +    if S == brank: -    L.append(list(map(str, s))) -for i in range(W): -    for l in L: -        if l[i] != ".": -            break -    else: -        ban.append(i) -        continue -for l in L: -    ans = "" -    for i in range(W): -        if i in ban: +    L.append(list(map(str, S))) +if L: +    L1 = list(zip(*L)) +    brank = tuple(["." for _ in range(len(L1[0]))]) +    ans = [] +    for l in L1: +        if l == brank: -        ans += l[i] -    print(ans) +        ans.append(l) +    for a in zip(*ans): +        print(("".join(a)))