Problem:
 Score : 200 points    Problem Statement There is a grid of squares with H horizontal rows and W vertical columns.
The square at the i -th row from the top and the j -th column from the left is represented as (i, j) .
Each square is black or white.
The color of the square is given as an H -by- W matrix (a_{i, j}) .
If a_{i, j} is . , the square (i, j) is white; if a_{i, j} is # , the square (i, j) is black.  Snuke is compressing this grid.
He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:   Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.   It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.
Find the final state of the grid.      Constraints  1 \leq H, W \leq 100  a_{i, j} is . or # .  There is at least one black square in the whole grid.         Input Input is given from Standard Input in the following format:  H  W  a_{1, 1}...a_{1, W}  :  a_{H, 1}...a_{H, W}       Output Print the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.        Sample Input 1 4 4
##.#
....
##.#
.#.#      Sample Output 1 ###
###
.##  The second row and the third column in the original grid will be removed.       Sample Input 2 3 3
#..
.#.
..#      Sample Output 2 #..
.#.
..#  As there is no row or column that consists only of white squares, no operation will be performed.       Sample Input 3 4 5
.....
.....
..#..
.....      Sample Output 3 #       Sample Input 4 7 6
......
....#.
.#....
..#...
..#...
......
.#..#.      Sample Output 4 ..#
#..
.#.
.#.
#.#

Solution (Python):
def main():
    H, W = map(int, input().split())
    a = [input() for _ in range(H)]

    
    
    ans = editorial(H, W, a)
    for x in ans:
        print(*x, sep="")


def editorial(H, W, a):
    
    row = [False] * H
    col = [False] * W

    for i in range(H):
        for j in range(W):
            if a[i][j] == "
                row[i] = True
                col[j] = True

    ans = []
    for i in range(H):
        if not row[i]:
            continue

        line = []
        for j in range(W):
            if col[j]:
                line.append(a[i][j])
        ans.append(line)

    if not ans:
        return [[]]

    return ans


def T(H, W, a):
    """
    転置
    本番ではバグらせるのを恐れて愚直に実装した
    """
    b = []
    c = []
    for line in a:
        if len(line) != line.count("."):
            b.append(line)

    for line in zip(*b):
        if len(line) != line.count("."):
            c.append(line)

    if not c:
        return [[]]

    return list(zip(*c))


def f(H, W, a):
    b = []
    for line in a:
        if len(line) != line.count("."):
            b.append(line)

    if not b:
        return [[]]

    idxes = []
    for x in range(len(a[0])):
        y = sum(1 for i in range(len(b)) if b[i][x] == ".")
        if y != len(b):
            idxes.append(x)

    if not idxes:
        return [[]]

    ans = []
    for i in range(len(b)):
        line = []
        for j in range(len(a[0])):
            if j in idxes:
                line.append(b[i][j])
        ans.append(line)

    return ans


if __name__ == '__main__':
    main()

Solution (Python):
h, w = map(int, input().split())
array = [input() for i in range(h)]


def delete(array):
    for i in range(len(array) - 1, -1, -1):
        if ''.join(list(set(list(array[i])))) == '.':
            del array[i]

delete(array)
array = list(map(list, zip(*array)))
delete(array)
array = list(map(list, zip(*array)))

for i in range(len(array)):
    print (''.join(array[i]))

Solution (Python):
h, w = map(int, input().split())
 
a = [''] * h
 
for i in range(h):
    a[i] = input()
    
row = [False] * h
col = [False] * w
 
for i in range(h):
    for j in range(w):
        if a[i][j] == '
            row[i] = True
            col[j] = True
 
for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j], end='')
        print()

Solution (Python):
h, w = map(int, input().split())
a = [''] * h
for i in range(h):
	a[i] = input()

row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if a[i][j] == '
			row[i] = True
			col[j] = True

for i in range(h):
	if row[i]:
		for j in range(w):
			if col[j]:
				print(a[i][j], end = '')
		print()

Solution (Python):
str = input()
a,b = [int(x) for x in str.split()]
r = [0] * a
c = [0] * b
s = []
for i in range(0,a):
	str = input()
	s.append(str)
	for j in range(0,b):
		if str[j] == '
			r[i] += 1
			c[j] += 1
for i in range(0,a):
	if r[i] != 0:
		str = s[i]
		for j in range(0,b):
			if c[j] != 0:
				print(str[j],end="")
		print()

Solution (Python):
h,w=map(int,input().split())
a=[list(input()) for _ in range(h)]
s=[]
for i in a:
  if(i.count("
a = [list(x) for x in zip(*s)]
s=[]
for i in a:
  if(i.count("
a = [list(x) for x in zip(*s)]
for i in a:print("".join(i))

Solution (Python):

import numpy as np

def trans(l):
    l=np.array(l)
    l=l.T
    l=l.tolist()
    return l

h,w=map(int,input().split())
temp1=[]
temp2=[]
ans=[]

for i in range(h):
    ans.append(list(input()))

for i in ans[:]:
    if set(i)!={'.'}:
        temp1.append(i)

     
ans=trans(temp1)

for i in ans[:]:
    if set(i)!={'.'}:
        temp2.append(i)

ans=trans(temp2)
        
for i in ans:
    print(''.join(i))

Solution (Python):
def getinputdata():

    array_result = []    
    array_result.append(input().split(" "))

    flg = True

    try:
        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

h = int(arr_data[0][0])
w = int(arr_data[0][1])

arr_temp01=[]
for i in range(1,1+h):
    
    if arr_data[i][0]!= w * ".":
        
        arr_temp01.append(arr_data[i][0]) 
    else:
        h-=1

arr_temp02=[]
for v in list(zip(*arr_temp01)):
    
    if "".join(v) != h*".":
    
        arr_temp02.append("".join(v))
    else:
        w-=1
        
for v in list(zip(*arr_temp02)):
    
    print("".join(v))

Solution (Python):
s = [f for f in open(0).read().split() if '
s = [''.join([s[j][i] for j in range(len(s))]) for i in range(len(s[0]))]
s = [f for f in s if '
s = [''.join([s[j][i] for j in range(len(s))]) for i in range(len(s[0]))]
print(*s, sep='\n')

Solution (Python):
s = [f for f in open(0).read().split() if '
s = [''.join([s[j][i] for j in range(len(s))]) for i in range(len(s[0]))]
s = [f for f in s if '
s = [''.join([s[j][i] for j in range(len(s))]) for i in range(len(s[0]))]
print(*s, sep='\n')

Solution (Python):
s = [f for f in open(0).read().split() if '
s = [''.join([s[j][i] for j in range(len(s))]) for i in range(len(s[0]))]
s = [f for f in s if '
s = [''.join([s[j][i] for j in range(len(s))]) for i in range(len(s[0]))]
print(*s, sep='\n')

Solution (Python):

import numpy as np
h, w =  map(int, input().split())


gird_colors = np.array([])
for _ in range(h):
    tmp_row = np.array(list(input()))
    if "
        gird_colors = np.concatenate((gird_colors, tmp_row))
gird_colors = gird_colors.reshape(-1, w)


del_count = 0
for wi in range(w):
    if "
        gird_colors = np.delete(gird_colors, wi - del_count, 1)
        del_count += 1


for line_val in gird_colors:
    print("".join(line_val))

Solution (Python):
h, w = map(int, input().split())

def checkLine(_h,_w):
  flag = True
  for i in range(0,h):
    if a[i][_w] == '
      flag = False

  if flag:
    return True

  flag = True
  for i in range(0,w):
    if a[_h][i] == '
      flag = False

  if flag:
    return True

  return False

a = []
for i in range(0,h):
  a += input().split()

for i in range(0,h):
  str = ""
  for j in range(0,w):
    if checkLine(i,j) == False:
      str = str + a[i][j]
  if str != "":
    print(str)

Solution (Python):
H,W = map(int,input().split(" "))
field = []
row_0 = ["." for i in range(W)]
for i in range(H):
    row_i = list(input())
    if row_i == row_0:
        H -= 1
    else:
        field.append(row_i)
col_0 = ["." for i in range(H)]
for i in range(W)[::-1]:
    col_i = []
    for j in range(H):
        col_i.append(field[j][i])
    if col_i == col_0:
        for j in range(H):
            del field[j][i]

for i in range(len(field)):
    print("".join(field[i]))

Solution (Python):
h,w=map(int,input().split())
d=[list(input())  for i in range(h)]
for i in range(w)[::-1]:
    if not "
        for j in range(h):del d[j][i]
for i in d:
    if "

Solution (Python):
h,w=map(int,input().split())
grid=[list(input())  for i in range(h)]
for i in range(w)[::-1]:
    a=[grid[j][i] for j in range(h)]
    if not "
        for j in range(h):
            del grid[j][i]
for i in grid:
    if "

Solution (Python):
import sys
y = input().split()
H = int(y[0])
W = int(y[1])
x = list()
for i in range(H):
    x.append(input())

flagH = list()
flagW = list()
for i in range(H):
    flagH.append(False)
for j in range(W):
    flagW.append(False)

for i in range(H):
    for j in range(W):
        if x[i][j] == "
            flagH[i] = True
            flagW[j] = True

for i in range(H):
    for j in range(W):
        if flagH[i] and flagW[j]:
            sys.stdout.write(x[i][j])
    if flagH[i]:
        print()

Solution (Python):
h, w = map(int, input().split())
a = [[c for c in input()] for i in range(h)]

ah, aw = [0] * h, [0] * w
for i in range(h):
    for j in range(w):
        if a[i][j] == '
            ah[i] = aw[j] = True
ans = ''
for i in range(h):
    for j in range(w):
        if ah[i] and aw[j]:
            ans += a[i][j]
    if ah[i]:
        ans += '\n'
print(ans)

Solution (Python):
H,W = map(int,input().split())
a = []
for i in range(H):
    a.append(input().split())
g = []
r = []
for i in range(H):
    for j in range(W):
        if a[i][0][j] == "
            g.append(i)
            break

for i in range(W):
    for j in range(H):
        if a[j][0][i] == "
            r.append(i)
            break

ans = ""
for i in g:
    for j in r:
        ans += a[i][0][j]
    print(ans)
    ans = ""

Solution (Python):
h, w = input().split()
h = int(h)
w = int(w)
lines = list()
c = [0]*w
for _ in range(h):
    line = input()
    if line=="."*w:
        continue
    lines.append(line)
    for i in range(w):
        if line[i]==".":
            c[i] += 1
h = len(lines)
ans = list()
for j in range(h):
    line = ""
    for i in range(w):
        if c[i] != h:
            line += lines[j][i]
    ans.append(line)
print("\n".join(ans))

Solution (Python):
h,w=map(int, input().split())
a=[input() for _ in range(h)]
ta=[]
tb=[]
tc=[]
for x in a:
    j=False
    for y in x:
        if y=='
            j=True
    if j:
        ta.append(x)
for i in range(1,w+1):
    t=[ta[j][-i] for j in range(len(ta))]
    j=False
    for x in t:
        if x=='
            j=True
    if j:
        tb.append(t)
for i in range(len(tb[0])):
    t=[tb[-j][i] for j in range(1,len(tb)+1)]
    print("".join(t))

Solution (Python):
H,W = (int(i) for i in input().split())

a = [0 for i in range(H)]

for i in range(H):
    a[i] = list(input())

count = 0
check = []
n = 0
for i in range(H):
    for j in range(W):
        if a[i-n][j] == '
            count = 1
            break
    if count == 0:
        del a[i-n]
        n += 1
    count = 0

ck = []
n = 0
for i in range(W):
    for j in range(len(a)):
        if a[j][i] == '
            count = 1
            break
    if count == 0:
        ck.append(i)
    count = 0

for i in ck:
    for j in range(len(a)):
        del a[j][i-n]
    n += 1

ans = ''
for i in range(len(a)):
    for j in a[i]:
        ans += j
    print(ans)
    ans = ''

Solution (Python):

H, W = map(int, input().split())
a, ans = [], []
for i in range(H):
    temp = input()
    if temp == '.'*W:
        continue
    a.append(temp)
    ans.append([])

for i in range(W):
    for j in a:
        if j[i] == '
            break
    else:
        continue
    for j,k in zip(a,ans):
        k.append(j[i])
for i in ans:
    print(''.join(i))

Solution (Python):
h,w = map(int,input().split())
a = []
for i in range(h):
    atemp = list(input())
    a.append(atemp)


i = 0
counter = 0
line = 0
while counter < h:
    k = 0
    check = True
    while k<w and check:
        if a[i][k] == "
            check = False
        else:
            k += 1
    if check:
        a.pop(i)
        line += 1
    else:
        i += 1
    counter += 1


i = 0
k = 0
counter = 0
while counter < w:
    i = 0
    check = True
    while i < h-line and check:
        if a[i][k] == "
            check = False
        else:
            i += 1
    if check:
        for j in range(len(a)):
            a[j].pop(k)
    else:
        k += 1
    counter += 1

for i in range(len(a)):
    for k in range(len(a[i])):
        if k != len(a[i]) -1:
            print(a[i][k],end = "")
        else:
            print(a[i][k])

Solution (Python):
h, w = tuple(map(int, input().split()))
grid = [list(input()) for _ in range(h)]

rm_h = [i for i, line in enumerate(grid) if all([x == '.' for x in line])]

rm_w = [i for i in range(w) if all([grid[j][i] == '.' for j in range(h)])]

arc_grid = [[grid[j][i] for i in range(w) if not i in rm_w] for j in range(h) if not j in rm_h]
for i in range(h-len(rm_h)):
  for j in range(w-len(rm_w)):
    print(arc_grid[i][j], end='')
  print('')

Solution (Python):
H, W = map(int, input().split())
a = [""] * H
for i in range(H):
    a[i] = input()

row = [False] * H
col = [False] * W
for i in range(H):
    for j in range(W):
        if a[i][j] == "
            row[i] = True
            col[j] = True

for i in range(H):
    if row[i]:
        for j in range(W):
            if col[j]:
                print(a[i][j], end = "")
        print()

Solution (Python):
from sys import stderr
from functools import reduce
from operator import add
def f(): return [int(i) for i in input().split()]
def yes(n): print("Yes" if n else "No")
def debug(*x, sep=" ", end="\n"):
    for item in x:
        stderr.write(repr(item))
        stderr.write(sep)
    stderr.write(end)


h, w = f()
grid = []
row = [False for _ in range(h)]
column = [False for _ in range(w)]

for i in range(h):
    ro = input()
    row[i] = (ro == '.' * w)
    grid.append(list(ro))

for j in range(w):
    column[j] = all([(grid[k][j] == '.') for k in range(h)])

for i in range(h):
    if row[i]:
        continue
    for j in range(w):
        if not column[j]:
            print(grid[i][j], end='')
    print()

Solution (Python):
h, w = map(int, input().split())
a = [''] * h
for i in range(h):
	a[i] = input()
 
row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if a[i][j] == '
			row[i] = True
			col[j] = True
 
for i in range(h):
	if row[i]:
		for j in range(w):
			if col[j]:
				print(a[i][j], end = '')
		print()

Solution (Python):


def inpl(): return list(map(int, input().split()))

h, w = inpl()
A = []
for i in range(h):
    a = list(input())
    A.append(a)

rows = [False for _ in range(h)]
for i in range(h):
    if A[i] != ['.' for _ in range(w)]:
        rows[i] = True

B = list(map(list, zip(*A)))[:]  
cols = [False for _ in range(w)]
for i in range(w):
    if B[i] != ['.' for _ in range(h)]:
        cols[i] = True

ans = []
for i in range(h):
    if rows[i]:
        tmp = []
        for j in range(w):
            if cols[j]:
                tmp.append(A[i][j])
        if tmp:
            ans.append(tmp)

for i in range(len(ans)):
    print(''.join(ans[i]))

Solution (Python):
h, w = map(int, input().split())
a = [input() for w in range(h)]

for i in range(h)[::-1]:
    if "
        del a[i]
        h -= 1

n = []
for j in range(w):
    m = ["".join(t[j] for t in a)]
    if "
        n += m

for k in range(h):
    print("".join(u[k] for u in n))

Solution (Python):
H, W = map(int, input().split())
a = [input() for _ in range(H)]
row = [False] * H
col = [False] * W
for i in range(len(row)):
  for j in range(len(col)):
    if a[i][j] == '
      row[i] = col[j] = True

for i in range(len(row)):
  if row[i]:
    for j in range(len(col)):
      if col[j]:
        print(a[i][j], end = '')
    print()

Solution (Python):
H, W = map(int, input().split())
h = []
w = []
a = [""]*H
for i in range(H):
    a[i] = input()


for y in range(H):
    flag = True
    for x in range(W):
        if a[y][x] == "
            flag = False
            break
    if flag:
        h.append(y)

for x in range(W):
    flag = True
    for y in range(H):
        if a[y][x] == "
            flag = False
            break
    if flag:
        w.append(x)

for y in range(H):
    for x in range(W):
        if y not in h and x not in w:
            print(a[y][x], end="")
    if y not in h:
        print()

Solution (Python):
arr = []

h, w = [int(i) for i in input().split()]
for _ in range(h):
    arr.append(input())

result = []
for ar in arr:
    if not '
        continue
    result.append(ar)

h = len(result)
w = len(result[0])





result2 = []
for j in range(w):
    flag = True
    for i in range(h):
        if result[i][j] == '
            flag = False
    if flag:
        result2.append(j)

if result2:

    result3 = []
    for s in result:
        line = ''
        for i, c in enumerate(s):
            if i in result2:
                continue
            line += c
        result3.append(line)
else:
    result3 = result





for line in result3:
    print(line)

Solution (Python):
import numpy as np
H, W = map(int, input().split())
A = [list(input()) for i in range(H)]
A = [a for a in A if "
A = list(np.array(A).transpose())
A = [a for a in A if "
A = list(np.array(A).transpose())
for a in A:
    print("".join(a))

Solution (Python):

H, W = map(int, input().split())
a = [[c for c in input()] for _h in range(H)]


for h in range(H):
    if '
        for w in range(W):
            a[h][w] = ''
for w in range(W):
    if '
        for h in range(H):
            a[h][w] = ''

for h in range(H):
    line = ''.join(a[h])
    if line:
        print(''.join(a[h]))

Solution (Python):
H, W = map(int, input().split())
a = []
y = 0
while True:
    if y >= H:
        break
    x = 0
    A = list(input())
    cnt = 0
    while True:
        if x >= W:
            break
        if A[x] == ".":
            cnt += 1
        x += 1
    if cnt == W:
        H -= 1
    else:
        a.append(A)
        y += 1
x = 0
while True:
    if x >= W:
        break
    y = 0
    cnt = 0
    while True:
        if y >= H:
            break
        if a[y][x] == ".":
            cnt += 1
        y += 1
    if cnt == H:
        for i in range(H):
            del a[i][x]
        W -= 1
    else:
        x += 1

for i in range(H):
    for j in range(W):
        print(a[i][j], end = "")
    print()

Solution (Python):
H, W = map(int, input().split())

a = [input() for w in range(H)]

for i in range(H)[::-1]:
    if '
        del a[i]
        H -= 1

n = []

for j in range(W)[::-1]:
    m = [''.join(t[j] for t in a)]
    if '
        n += m

for k in range(H):
    print(''.join(u[k] for u in n[::-1]))

Solution (Python):
H, W = map(int, input().split())

a = [input() for w in range(H)]

for i in range(H)[::-1]:
    if '
        del a[i]
        H -= 1

n = []

for j in range(W)[::-1]:
    m = [''.join([t[j] for t in a])]
    if '
        n += m

for k in range(H):
    print(''.join(u[k] for u in n[::-1]))

Solution (Python):


h,w=map(int,input().split())
a=[]
for i in range(h):
 t=input()
 if t=='.'*w:
  continue
 a.append(list(t))
b=list(map(list, zip(*a)))
c=[]
for i in range(len(b)):
 if all(x=='.' for x in b[i]):
  continue
 c.append(b[i])
l=list(map(list, zip(*c)))
for i in range(len(l)):
 print(''.join(l[i]))

Solution (Python):
h, w = map(int, input().split())

table = []
row = [0 for _ in range(h)]
column = [0 for _ in range(w)]
for j in range(h):
    temp = [] + list(input())
    table.append(temp)
    check = 0
    for i in range(w):
        if temp[i] == '
            check = 1
            column[i] = 1
    row[j] = check

for i in range(h):
    if row[i] == 0:
        continue

    temp = [] + table[i]
    for j in range(w):
        if column[j] == 0:
            temp[j] = ''

    print(''.join(temp))

Solution (Python):
H,W=map(int,input().split())
b=[]
for i in range(H):
    a=list(str(input()))
    if '
        b.append(a)

count=[0]*W

for i in b:

    for j in range(W):

        if i[j]=='
            count[j] += 1

ans=['']*len(b)

for i in range(len(b)):

    for j in range(W):

        if count[j]!=0:
            
            ans[i] += b[i][j]

for k in ans:

    print(k)

Solution (Python):
h, w = map(int, input().split())
a = []
for _ in range(h):
  t = list(input())
  if t.count('.') != w:
    a.append(t)
i = 0
while True:
  if i >= len(a[0]):break
  for t in a:
    if t[i] != '.':
      i += 1
      break
  else:
    for j in range(len(a)):
      del a[j][i]
for t in a:
  print(''.join(t))

Solution (Python):
h, w = map(int, input().split())
a = []
for _ in range(h):
  t = list(input())
  if t.count('.') != w:
    a.append(t)
i = 0
while True:
  if i >= len(a[0]):break
  for t in a:
    if t[i] != '.':
      i += 1
      break
  else:
    for j in range(len(a)):
      del a[j][i]
for t in a:
  print(''.join(t))

Solution (Python):
h,w=map(int,input().split())
s=list(input()for _ in[0]*h)
a=[0]*h
b=[0]*w
for i in range(h):
    f=0
    for j in range(w):f+=s[i][j]=='
    a[i]=f>0
for j in range(w):
    f=0
    for i in range(h):f+=s[i][j]=='
    b[j]=f>0
for i in range(h):
    if not a[i]:continue
    for j in range(w):
        if b[j]:print(s[i][j],end='')
    print()

Solution (Python):
h,w = map(int, input().split())
a = [list(input()) for _ in range(h)] 

row, col = [False]*h, [False]*w
for i in range(h):
    for j in range(w):
        if a[i][j] == '
            row[i], col[j] = True, True
for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j], end='')
        print()

Solution (Python):
H, W = map(int, input().split())

wlist = []

flagc = [0 for i in range(W)]
for i in range(H):
    rtmp = str(input())
    rtmp_s = list(rtmp)

    flag = 0
    for j in range(len(rtmp_s)):
        if rtmp_s[j] == '
            flag += 1
            flagc[j] += 1

    if flag == 0:
        pass
    else:
        wlist.append(rtmp_s)


count = 0
for i in range(W):
    if flagc[i] == 0:
        count += 1

ans = []
for i in range(len(wlist)):
    ansr = []
    k = 0
    for j in range(W):
        if flagc[j] == 0:
            pass
        else:
            ansr.append(wlist[i][k])
        k += 1

    ans.append(ansr)


for i in range(len(ans)):
    for j in range(len(ans[0])):
        print(ans[i][j], end='')
    print('')

Solution (Python):
H,W=map(int,input().split())
A=[input() for x in range(H)]

ans=[]

for i in range(H):
  ch=False
  for j in range(W):
    if A[i][j]=='
      ch=True
      break
  if ch:
    ans.append(A[i])

ans=list(zip(*ans))
ans1=[]

for i in range(W):
  ch=False
  for j in range(len(ans[i])):
    if ans[i][j]=='
      ch=True
      break
  if ch:
    ans1.append(ans[i])
    
ans1=list(zip(*ans1))

for i in range(len(ans1)):
  print("".join(list(ans1[i])))

Solution (Python):
H, W = [int(_) for _ in input().split()]

A = [input() for i in range(H)]

A = ["".join(row) for row in zip(*A) if row.count("
A = ["".join(row) for row in zip(*A) if row.count("

print("\n".join(A))

Solution (Python):

H, W = map(int, input().split())
a = [None] * H
for i in range(H):
    a[i] = input()

c = [False] * W
r = [False] * H
for i in range(H):
    for j in range(W):
        if a[i][j] == '
            break
        if j == W - 1:
            r[i] = True
for j in range(W):
    for i in range(H):
        if a[i][j] == '
            break
        if i == H - 1:
            c[j] = True

s = ''
for i in range(H):
    for j in range(W):
        if r[i] or c[j]:
            continue
        s += a[i][j]
    if not s:
        continue
    print(s)
    s = ''

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

a = list()
for height in range(H):
    line = input()
    if line == '.' * W:
        pass
    else:
        a.append(list(line))


a = [list(x) for x in zip(*a)]
a_trim = list()
for a_row in a:
    if ''.join(a_row) == '.' * len(a_row):
        pass
    else:
        a_trim.append(a_row)

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

for row in a:
    print(''.join(row))

Solution (Python):


h, w = map(int, input().split())
a = [''] * h
for i in range(h):
	a[i] = input()
	
row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if a[i][j] == '
			row[i] = True
			col[j] = True
			
for i in range(h):
	if row[i]:
		for j in range(w):
			if col[j]:
				print(a[i][j], end='')
		print()

Solution (Python):



def check_column(grid):
    H_temp = len(grid)
    W_temp = len(grid[0])
    column_index = []    
    for i in range(W_temp):
        count_dot_column = 0
        for j in range(H_temp):
            if grid[j][i] == ".":
                count_dot_column += 1
        
        
        
        
        if count_dot_column == H_temp:
            column_index.append(i)
    if len(column_index) != 0:
        return True,column_index
    else:
        return False,column_index




def del_column(grid,del_column_index):
    H_temp = len(grid)
    
    for i in range(H_temp):
        del grid[i][del_column_index]
    return grid





H,W = map(int,input().split())
grid = []
judge = True



for i in range(H):
    temp_input = input()
    count_dot = temp_input.count(".")
    if count_dot == W:
        pass
    else:
        grid.append(list(temp_input))




while judge:
    judge,del_column_index = check_column(grid)
    
    if judge:
        
        grid = del_column(grid, del_column_index[0])
        



for i in range(len(grid)):
    print("".join(grid[i]))

Solution (Python):
def main():
    H, W = map(int, input().split())
    a = [input() for _ in range(H)]

    
    ans = T(H, W, a)
    for x in ans:
        print(*x, sep="")


def T(H, W, a):
    """
    転置
    本番ではバグらせるのを恐れて愚直に実装した
    """
    b = []
    c = []
    for line in a:
        if len(line) != line.count("."):
            b.append(line)

    for line in zip(*b):
        if len(line) != line.count("."):
            c.append(line)

    if not c:
        return [[]]

    return list(zip(*c))


def f(H, W, a):
    b = []
    for line in a:
        if len(line) != line.count("."):
            b.append(line)

    if not b:
        return [[]]

    idxes = []
    for x in range(len(a[0])):
        y = sum(1 for i in range(len(b)) if b[i][x] == ".")
        if y != len(b):
            idxes.append(x)

    if not idxes:
        return [[]]

    ans = []
    for i in range(len(b)):
        line = []
        for j in range(len(a[0])):
            if j in idxes:
                line.append(b[i][j])
        ans.append(line)

    return ans


if __name__ == '__main__':
    main()

Solution (Python):
H, W = list(map(int, input().split()))
squareA = [list(input()) for i in range(H)]
squareB = [[squareA[i][j] for i in range(H)] for j in range(W)]
h = []
w = []
for i in range(H):
  if '
    h.append(i)
for i in range(W):
  if '
    w.append(i)
for i in range(H):
  if i not in h:
    for j in range(W):
      if j not in w:
        print(squareA[i][j], end = "")
    print(end = "\n")

Solution (Python):
h, w = (int(v) for v in input().split())
a = [input() for _ in range(h)]

my = [True for _ in range(h)]
mx = [True for _ in range(w)]

for y in range(h):
    for x in range(w):
        if a[y][x] != '.':
            break
    else:
        my[y] = False

for x in range(w):
    for y in range(h):
        if a[y][x] != '.':
            break
    else:
        mx[x] = False

s = ''
for y in range(h):
    for x in range(w):
        if my[y] and mx[x]:
            s += a[y][x]
    if my[y]:
        s += '\n'
print(s, end='')

Solution (Python):
h, w = (int(v) for v in input().split())
a = [input() for _ in range(h)]

my = [True for _ in range(h)]
mx = [True for _ in range(w)]

for y in range(h):
    for x in range(w):
        if a[y][x] != '.':
            break
    else:
        my[y] = False

for x in range(w):
    for y in range(h):
        if a[y][x] != '.':
            break
    else:
        mx[x] = False

for y in range(h):
    for x in range(w):
        if my[y] and mx[x]:
            print(a[y][x], end='')
    if my[y]:
        print()

Solution (Python):
H,W = map(int,input().split())
A = []
for i in range(H):
    a = input()
    A.append(a)

ansW,ansH = [],[]
for hi in range(H):
    for wi in range(W):
        if A[hi][wi] == "
            break
    else:
        ansH.append(hi)
for wi in range(W):
    for hi in range(H):
        if A[hi][wi] == "
            break
    else:
        ansW.append(wi)

Ans = []
for hi in range(H):
    if hi not in ansH:
        ans = ""
        for wi in range(W):
            if wi not in ansW:
                ans += A[hi][wi]
        Ans.append(ans)

for ans in Ans:
    print(ans)

Solution (Python):
import numpy as np
H, W = map(int, input().split())
a = []
for i in range(H):
    ai = input()
    if len(set(ai)) == 1 and ai[0] == '.':
        continue
    else:
        a.append([ai[j] for j in range(len(ai))])
a = np.asarray(a).T
indices = []
for i in range(len(a)):
    if len(set(a[i])) == 1 and a[i][0] == '.':
        continue
    else:
        indices.append(i)
a = a[indices]
for ai in a.T:
    for aij in ai:
        print(aij, end='')
    print()

Solution (Python):
import sys;input()
for r in zip(*[c for c in zip(*[r for r in sys.stdin if'

Solution (Python):
import sys
input()
rows=[row for row in sys.stdin if '
cols=[col for col in zip(*rows) if '
for row in zip(*cols):print(*row, sep='')

Solution (Python):
h,w = map(int, input().split())
field = []
for _ in range(h):
    field.append(input())


hasb_row = []
for hi in range(h):
    for wj in range(w):
        if field[hi][wj] == "
            hasb_row.append(hi)
            break


hasb_col = []
for wj in range(w):
    for hi in range(h):
        if field[hi][wj] == "
            hasb_col.append(wj)
            break
        

f_ans = [[] for _ in range(len(hasb_row))]
for i, hi in enumerate(hasb_row):
    for j, wj in enumerate(hasb_col):
        f_ans[i].append(field[hi][wj:wj+1])
        
for hi in range(len(hasb_row)):
    print("".join(f_ans[hi]))

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    h,w = LI()
    a = [[c for c in S()] for _ in range(h)]
    b = []
    for i in range(h):
        if '
            b.append(a[i])
    c = [''] * len(b)
    for j in range(w):
        f = False
        for i in range(len(b)):
            if b[i][j] == '
                f = True
                break
        if f:
            for i in range(len(b)):
                c[i] += b[i][j]

    return '\n'.join(c)



print(main())