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

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

A = list(zip(*a))

skip_h = [] 

skip_w = []

for i in range(h):

  if a[i] == ["."] * w: skip_h.append(i)

for i in range(w):

  if A[i] == tuple(".") * h: skip_w.append(i)



for i in range(h):

  if i in skip_h: continue

  ans = ""

  for j in range(w):

    if j in skip_w: continue

    ans += a[i][j]

  print(ans)
h,w = list(map(int, input().split()))

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



skip = []

for i in range(h):

  if a[i] == ["."] * w: skip.append(i)



a = list(zip(*a))

d = []

for i in range(w):

  if set(a[i]) == {"."}: d.append(i)

d.sort(reverse=True)

for i in d:

  a.pop(i)



a = list(zip(*a))

for i in range(h):

  if i in skip: continue

  else:

    print(("".join(a[i])))
h, w = list(map(int, input().split()))
a = [list(eval(input())) for _ in range(h)]
A = list(zip(*a))
skip_h = []
skip_w = []
for i in range(h):
    if a[i] == ["."] * w:
        skip_h.append(i)
for i in range(w):
    if A[i] == tuple(".") * h:
        skip_w.append(i)
for i in range(h):
    if i in skip_h:
        continue
    ans = ""
    for j in range(w):
        if j in skip_w:
            continue
        ans += a[i][j]
    print(ans)

h, w = list(map(int, input().split()))
a = [list(eval(input())) for _ in range(h)]
skip = []
for i in range(h):
    if a[i] == ["."] * w:
        skip.append(i)
a = list(zip(*a))
d = []
for i in range(w):
    if set(a[i]) == {"."}:
        d.append(i)
d.sort(reverse=True)
for i in d:
    a.pop(i)
a = list(zip(*a))
for i in range(h):
    if i in skip:
        continue
    else:
        print(("".join(a[i])))

-A = list(zip(*a)) -skip_h = [] -skip_w = [] +skip = [] -        skip_h.append(i) +        skip.append(i) +a = list(zip(*a)) +d = [] -    if A[i] == tuple(".") * h: -        skip_w.append(i) +    if set(a[i]) == {"."}: +        d.append(i) +d.sort(reverse=True) +for i in d: +    a.pop(i) +a = list(zip(*a)) -    if i in skip_h: +    if i in skip: -    ans = "" -    for j in range(w): -        if j in skip_w: -            continue -        ans += a[i][j] -    print(ans) +    else: +        print(("".join(a[i])))