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

src = [eval(input()) for i in range(H)]

cols = list(zip(*src))

for row in src:

    if all([c=='.' for c in row]): continue

    out = ''

    for i,c in enumerate(row):

        if all([c=='.' for c in cols[i]]): continue

        out += c

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

src = [eval(input()) for i in range(H)]



del_r = []

for i in range(H):

    if all([c=='.' for c in src[i]]):

        del_r.append(i)



del_c = []

for i,col in enumerate(zip(*src)):

    if all([c=='.' for c in col]):

        del_c.append(i)



for i in range(H):

    if i in del_r: continue

    ans = ''

    for j in range(W):

        if j in del_c: continue

        ans += src[i][j]

    print(ans)
H, W = list(map(int, input().split()))
src = [eval(input()) for i in range(H)]
cols = list(zip(*src))
for row in src:
    if all([c == "." for c in row]):
        continue
    out = ""
    for i, c in enumerate(row):
        if all([c == "." for c in cols[i]]):
            continue
        out += c
    print(out)

H, W = list(map(int, input().split()))
src = [eval(input()) for i in range(H)]
del_r = []
for i in range(H):
    if all([c == "." for c in src[i]]):
        del_r.append(i)
del_c = []
for i, col in enumerate(zip(*src)):
    if all([c == "." for c in col]):
        del_c.append(i)
for i in range(H):
    if i in del_r:
        continue
    ans = ""
    for j in range(W):
        if j in del_c:
            continue
        ans += src[i][j]
    print(ans)

-cols = list(zip(*src)) -for row in src: -    if all([c == "." for c in row]): +del_r = [] +for i in range(H): +    if all([c == "." for c in src[i]]): +        del_r.append(i) +del_c = [] +for i, col in enumerate(zip(*src)): +    if all([c == "." for c in col]): +        del_c.append(i) +for i in range(H): +    if i in del_r: -    out = "" -    for i, c in enumerate(row): -        if all([c == "." for c in cols[i]]): +    ans = "" +    for j in range(W): +        if j in del_c: -        out += c -    print(out) +        ans += src[i][j] +    print(ans)