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

a = list(eval(input()) for _ in range(H))

h = []

w = []

w_list = []



for i in range(H):

  if a[i] == "." * W:

    h.append(i)

  for j in range(W):

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

      w.append(j)



w_set = list(set(w))

for x in range(len(w_set)):

  if w.count(w_set[x]) == H:

    w_list.append(w_set[x])



for i in range(H):

  A = ""

  if a[i] != "." * W:

    for j in range(W):

      if not j in w_list:

        A += a[i][j]

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

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



b = [list(x) for x in zip(*a)]



n = []

for i in range(W):

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

    n.append(i)



for A in a:

  if A == ["."] * W: continue

  if len(n) == 0: 

    print(("".join(A)))

    continue

  ans = ""

  for i in range(W):

    if i in n: continue

    ans += A[i]

  print(("".join(ans)))
H, W = list(map(int, input().split()))
a = list(eval(input()) for _ in range(H))
h = []
w = []
w_list = []
for i in range(H):
    if a[i] == "." * W:
        h.append(i)
    for j in range(W):
        if a[i][j] == ".":
            w.append(j)
w_set = list(set(w))
for x in range(len(w_set)):
    if w.count(w_set[x]) == H:
        w_list.append(w_set[x])
for i in range(H):
    A = ""
    if a[i] != "." * W:
        for j in range(W):
            if not j in w_list:
                A += a[i][j]
        print(A)

H, W = list(map(int, input().split()))
a = [list(eval(input())) for _ in range(H)]
b = [list(x) for x in zip(*a)]
n = []
for i in range(W):
    if b[i] == ["."] * H:
        n.append(i)
for A in a:
    if A == ["."] * W:
        continue
    if len(n) == 0:
        print(("".join(A)))
        continue
    ans = ""
    for i in range(W):
        if i in n:
            continue
        ans += A[i]
    print(("".join(ans)))

-a = list(eval(input()) for _ in range(H)) -h = [] -w = [] -w_list = [] -for i in range(H): -    if a[i] == "." * W: -        h.append(i) -    for j in range(W): -        if a[i][j] == ".": -            w.append(j) -w_set = list(set(w)) -for x in range(len(w_set)): -    if w.count(w_set[x]) == H: -        w_list.append(w_set[x]) -for i in range(H): -    A = "" -    if a[i] != "." * W: -        for j in range(W): -            if not j in w_list: -                A += a[i][j] -        print(A) +a = [list(eval(input())) for _ in range(H)] +b = [list(x) for x in zip(*a)] +n = [] +for i in range(W): +    if b[i] == ["."] * H: +        n.append(i) +for A in a: +    if A == ["."] * W: +        continue +    if len(n) == 0: +        print(("".join(A))) +        continue +    ans = "" +    for i in range(W): +        if i in n: +            continue +        ans += A[i] +    print(("".join(ans)))