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):
import sys
import numpy as np

def LI(): return [int(x) for x in sys.stdin.readline().split()]


if __name__ == "__main__":
    h, w = LI()
    a = []
    for _ in range(h):
        row = input()
        if row == '.'*w:
            continue
        else:
            a.append([e for e in row])

    b = []
    a_ = np.array(a).T
    for row in a_:
        if list(row) == ['.']*len(a):
            continue
        else:
            b.append(row)

    b = np.array(b).T
    for row in b:
        print(''.join(row))

Solution (Python):
H, W = map(int, input().split())
arr = []
count=0
for j in range(H):
    a=list(input())
    if '
        arr.append(a)
    else:
        count=count+1
        pass


arr=list(map(list, zip(*arr)))

num=[]
for j in range(W):

    if '
        pass
    else:
        num.append(j)  


num.reverse()


for i in num:
    del arr[i]
arr=list(map(list, zip(*arr)))

for i in range(H-count):
    print("".join(arr[i]))

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

arr = [raw_input() for i in range(h)]

ans = []
for i in range(h):
	count = 0
	for j in range(w):
		if arr[i][j] == '.':
			count += 1

	if count != w:
		ans.append(arr[i]) 


ret = [[] for i in range(len(ans))]
for i in range(w):
	count = 0
	for j in range(len(ans)):
		if ans[j][i] == '.':
			count += 1

	if count != len(ans):
		for j in range(len(ans)):
			ret[j].append(ans[j][i])

for i in ret:
	print ''.join(i)

Solution (Python):



def main():
    H, W = map(int, raw_input().split())
    a = [0] * H
    for i in xrange(H):
        a[i] = list(raw_input())

    b = a
    
    for i in xrange(W):
        v = ""
        for j in xrange(len(a)):
            v += a[j][i]

        if set(v) == set(".
            pass
        else:
            for j in xrange(len(a)):
                a[j][i] = "e"

    b = []
    for ele in a:
        val = ''.join(ele).replace("e", "")
        b.append(list(val))

    for i in xrange(len(b)):
        v = ""
        for j in xrange(len(b[0])):
            v += b[i][j]

        if set(v) == set(".
            pass
        else:
            for j in xrange(len(b[0])):
                b[i][j] = "e"

    c = []
    for ele in b:
        val = ''.join(ele).replace("e", "")
        if val != '':
            print(val)


if __name__ == "__main__":
    main()

Solution (Python):
import math

H,W=(int(i) for i in input().split())
li=[]
for i in range(0,H):
    li2=[]
    S1=input()
    for j in range(0,W):
        li2.append(S1[j])
        

    li.append(li2)
    

Flag=False

for i in range(0,H):
    
    for j in range(0,W):
        if (li[i][j]=="." or li[i][j]=="Remove"):
            Flag=True
        else:
            Flag=False
            break

    if Flag==True:
         for j in range(0,W):
            li[i][j]="Remove"
          


    

for i in range(0,W):
    
    for j in range(0,H):
         if (li[j][i]=="." or li[j][i]=="Remove"):
            Flag=True
         else:
            Flag=False
            break

    if Flag==True:
         for j in range(0,H):
            li[j][i]="Remove"
       
for i in range(0,H):
    for j in range(0,W):
        if (li[i][j]=="Remove"):
            li[i][j]=""


for i in range(0,H):
    count=0
    for j in range(0,W):
        
        if (li[i][j]==""):
            Flag=True
            count+=1
        else:
            Flag=False
        
        print(str(li[i][j]),end="")

    if count!=W:
        print("")

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

W_bList = []
H_bList = []


for i in range(W):
    w = []
    for j in range(H):
        w.append(a[j][i])  

    
    if len(set(w)) == 2 or set(w) == set("
        W_bList.append(i)


for i in range(H):
    h = []
    for j in range(W):
        h.append(a[i][j])  

    
    if len(set(h)) == 2 or set(h) == set("
        H_bList.append(i)




for hl in H_bList:

    ans = ""
    
    for wl in W_bList:
        ans += str(a[hl][wl])

    print(ans)

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

W_bList = []
H_bList = []


for i in range(W):
    w = []
    for j in range(H):
        w.append(a[j][i])  

    
    if len(set(w)) == 2 or set(w) == set("
        W_bList.append(i)


for i in range(H):
    h = []
    for j in range(W):
        h.append(a[i][j])  

    
    if len(set(h)) == 2 or set(h) == set("
        H_bList.append(i)




for hl in H_bList:

    ans = ""
    
    for wl in W_bList:
        ans += str(a[hl][wl])

    print(ans)

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

squares = []
for i in range(h):
    row = list(input())
    squares.append(row)

while True:
    continue_judge = False

    for i,l in enumerate(squares): 
        if "
            squares.pop(i)
            h -= 1

    for i in range(w): 
        delete_judge = True

        for l in squares:
            if l[i] == "
                delete_judge = False
                break

        if delete_judge == True:
            for l in squares:
                l.pop(i)
            w -= 1
            continue_judge = True
            break

    if continue_judge == False:
        break


for l in squares:
    for i in l:
        print(i, end = "")
    print("")

Solution (Python):
"""
上手い方法思い付きませんでした（圧縮→行列転置→圧縮→行列転置は悪くなさそう）
～～～登場人物～～～
s：入力
ss：入力から行を圧縮したもの
　　（s[i]にピリオド以外のものがある場合にappendしたやつ）
  
answer：ssから頑張って列を圧縮したもの
       （ss[i][j]がすべてのjでピリオドだった場合のjをcolumn_compに格納
       　その後、column_compに含まれていないjにおいて、answer[i] += ss[i][j] ）

"""

h, w = [int(i) for i in input().split()]

s = []
for i in range(h):
  s.append(input())



row = 0
ss = []
for i in range(h):
  if s[i].count(".") != w:
    ss.append(s[i])
    row += 1

    

column_comp = []
for j in range(w):
  period_count = 0
  for i in range(row):

    if ss[i][j] == ".":
      period_count += 1
  if period_count == row:
    column_comp.append(j)


answer = ["" for i in range(row)]
for i in range(row):
  for j in range(w):
    if j not in column_comp:
      answer[i] += ss[i][j]
  print(answer[i])

Solution (Python):
if __name__ == '__main__':
    from collections import deque

    la = list(map(int, input().split()))

    nl = deque([])

    for i in range(0, la[0]):
        nl.append(list(input()))

    for j in range(len(nl)):
        if '
            nl[j].clear()

    sl = [u for u in nl if u]

    for c in range(0, la[1]):
        zl = [row[c] for row in sl]
        
        if '
            for d in sl:
                d[c] = ''

    for e in range(len(sl)):
        sl[e] = [u for u in sl[e] if u]

    for k in sl:
        print(''.join(k))

Solution (Python):
h,w = input().split()
h = int(h)
w = int(w)
inp = []
count = 0
for i in range(h):
    tmp_input = list(input())
    if '
        inp.append(tmp_input)
    else:
        count += 1
inp2 = list(map(list,zip(*inp)))
youso = []
for i in range(w):
    if "
        pass
    else:
        youso.append(i)
youso.reverse()
if len(youso) != 0:
    for i in range(len(youso)):
        for j in range(h-count):
            del inp[j][youso[i]]
else:
    pass
for i in range(len(inp)):
    mojiretu = ''.join(inp[i])
    print(mojiretu)

Solution (Python):
import math
H,W=list(map(int,input().split()))
grid=[]
for i in range(H):
    grid.append(input())
after=[]
for i in range(H):
    if grid[i] != '.'*W:
        after.append(grid[i])

H = len(after)
W = len(after[0])

flag = []
for i in range(H):
    r = []
    for j in range(W):
        r.append(1)
    flag.append(r)

for j in range(W):
    c = ''
    for i in range(H):
        c = c+after[i][j]
    if c == '.'*H:
        for k in range(H):
            flag[k][j] = 0
            W -= 1
    else:
        pass
out=[]
for i in range(H):
    out.append([])

for i in range(H):
    for j in range(len(after[0])):
        if flag[i][j] == 1:
            out[i].append(after[i][j])
        else:
            pass

for i in range(H):
    print(''.join(out[i]))

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

for h in range(H):
    s = input()
    if '
        grid.append(s)

dl = []
ans = [''] * len(grid)
for i in range(W):
    l = ''
    for j in range(len(grid)):
        g = grid[j]
        ans[j] += g[i]
        l += g[i]
    if '
        for k in range(len(grid)):
            ans[k] = ans[k][:-1]

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

Solution (Python):
ys, xs = map(int, input().split())
mas = []
for y in range(ys):
    mas.append(list(input()))
import numpy as np
mas_new = []
mas = np.array(mas)

for ma in mas:
    if (ma == '.').sum() != xs:
        mas_new.append(ma.tolist())
        
mas = np.array(mas_new).T

mas_new = []

for ma in mas:
    if (ma == '.').sum() != mas.shape[1]:
        mas_new.append(ma.tolist())
    
mas = np.array(mas_new).T
mas = mas.tolist()
for ma in mas:
    print(''.join(ma))

Solution (Python):
def main():
    H, W = list(map(int, input().split(" ")))
    a = []
    for r in range(H):
        a += [input()]
    output = solve(H, W, a)
    for s in output:
        print(s)
    return




def solve(H, W, a):
    """
    解答のコード
    """
    index_list = []
    for _r in range(H):
        for _c in range(W):
            if a[_r][_c] is not ".":
                break
            if _c == W-1:
                index_list += [_r]
    j = 0
    for i in index_list:
        del a[i-j]
        j += 1

    index_list = []
    a = list(map(list, zip(*a)))
    for _r in range(len(a)):
        for _c in range(len(a[0])):
            if a[_r][_c] is not ".":
                break
            if _c == len(a[0])-1:
                index_list += [_r]
    j = 0
    for i in index_list:
        del a[i-j]
        j += 1
    a = list(map(list, zip(*a)))
    a = [ "".join(a[i]) for i in range(len(a))]
    return a



if __name__ == "__main__":
    main()

Solution (Python):

def compression(init, matrix):
	
	mir = []
	
	for row in matrix:
		if "
			mir.append(row)
	matrix = []
	
	mir = list(map(list, zip(*mir)))
	
	for row in mir:
		if "
			matrix.append(row)
		
	matrix = list(map(list, zip(*matrix)))	
			
	
	return matrix


init = input().split(" ")
init = [int(c) for c in init]

matrix = [[] for j in range(init[0])]

for j in range(init[0]):
	matrix[j] = input()

result = compression(init, matrix)
for row in result:
	print("".join(row))

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

grid = []
for _ in range(H):
    row = input()
    if row[0] == "." and len(set(row)) == 1:
        H -= 1
        continue
    grid.append(row)

for i in range(W-1, -1, -1):
    if grid[0][i] == "
        continue
    for h in range(H):
        new_row = ""
        if i > 0:
            new_row += grid[h][:i]
        if i < W-1:
            new_row += grid[h][i+1:]
        grid[h] = new_row

for row in grid:
    print(row)

Solution (Python):


import numpy as np

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

masu = []
res = []
str1 = '.' * W

for i in range(H):
	str2 = input()
	if str1 != str2:
		masu.append(str2)

l = ['.'] * len(masu)
for i in range(W):
	tmp = [k[i] for k in masu]
	if tmp != l:
		res.append(tmp)

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

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

field = [[s for s in input()] for _ in range(h)]

tmp = ["" for _ in range(w)]
for i in range(h):
    for j in range(w):
        tmp[j] += field[i][j]

row = [s.count("
col = [s.count("

for i,r in enumerate(row):
    for j,c in enumerate(col):
       if not (r or c):
           print(field[i][j],end="")

    print()

Solution (Python):
H,W = [int(i) for i in input().split()]
table = []
for i in range(H):
  table.append(input())
 
table_ = []
for i in range(H):
  for j in range(W):
      if table[i][j] == '
          table_.append(table[i])
          break

ans = []
for i in range((W)):
    for j in range(len(table)):
        if table[j][i] == '
            ans.append(i)
            break

for line in table_:
    for i in ans:
        print(line[i],end = '')
    print()

Solution (Python):
H, W = map(int, input().split())
a = []
b = []
c = []
i = 0
j = 0
k = 0
while i < H:
    moji = input()
    if "
        a.append([m for m in moji])
    i += 1
while j < W:
    ls = [row[j] for row in a]
    if "
        b.append(ls)
    j += 1
while k < len(b[0]):
    ls = [row[k] for row in b]
    c.append(ls)
    k += 1
for row in c:
    print("".join(row))

Solution (Python):
import numpy as np

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

for h in range(H):
    i = input()
    if not '
        continue

    for n in range(len(i)):
        a[n].append(i[n])

b = []
for x in a:
    if not '
        continue
    b.append(x)

[print(''.join(x)) for x in np.array(b).T.tolist()]

Solution (Python):
import sys

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


for line in a[:]:
    if line.count('.') == len(line):
        a.remove(line)

if len(a)==0:
    sys.exit

b = []


for row in range(len(a[0])):
    tmp = []
    for line in range(len(a)):
        tmp.append(a[line][row])
    b.append(tmp)    

for line in b[:]:
    if line.count('.') == len(line):
        b.remove(line)
c=[]

for row in range(len(b[0])):
    tmp = []
    for line in range(len(b)):
        tmp.append(b[line][row])
    c.append(tmp)    


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

Solution (Python):
import numpy as np

n, m = list(map(int, input().split()))

board = []
for i in range(n):
    l = list(input())
    board.append(l)
board = np.array(board, dtype='unicode')

tmp = []
for i in range(board.shape[0]):
    if sum(board[i, :] == '.') == board.shape[1]:
        tmp.append(i)
board = np.delete(board, tmp, axis=0)

tmp = []
for i in range(board.shape[1]):
    if sum(board[:, i] == '.') == board.shape[0]:
        tmp.append(i)
board = np.delete(board, tmp, axis=1)

for i in range(board.shape[0]):
    for j in range(board.shape[1]):
        print(board[i, j], end='')
    print()

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

for i in range(H):
	a[i] = input()
	if a[i] == "."*W:
		h[i] = False
	for j in range(W):
		if a[i][j] == "
			w[j] = True

for i in range(H):
	if h[i]:
		z = ""
		for j in range(W):
			if w[j]:
				z += a[i][j]
		print(z)

Solution (Python):


h,w = map(int,raw_input().split())

a = []

for i in range(h): a.append(raw_input())

flags = [True] * (h+w)

for i in range(h):
    for j in range(w):
        if a[i][j] == "
            flags[i] = False
            flags[h+j] = False

i = 0
while True:
    if i>h-1: break
    if flags[i]:
        del a[i]
        del flags[i]
        h -= 1
        i -= 1
    i += 1

i = 0
while True:
    if i>w-1: break
    if flags[h+i]:
        w -= 1
        del flags[h+i]
        for j in range(h):
            a[j] = a[j][:i] + a[j][i+1:]
        i -= 1
    i += 1

for i in range(h):
    print a[i]

Solution (Python):
H, W = [int(_) for _ in input().split()]
l = []
del_list_H = []
del_list_W = []
for i in range(H):
    l.append(list(input()))

for i in range(H):
    t = 0
    for j in range(W):
        if l[i][j] == '.':
            t += 1
    if t == W:
        del_list_H.append(i)

counter = len(del_list_H)
for i in range(counter):
    del l[del_list_H[i]]
    del_list_H = [x-1 for x in del_list_H]
    H -= 1

for i in range(W):
    t = 0
    for j in range(H):
        if l[j][i] == '.':
            t += 1
    if t == H:
        del_list_W.append(i)

counter = len(del_list_W)
for i in range(counter):
    for j in range(H):
        del l[j][del_list_W[i]]
    del_list_W = [x-1 for x in del_list_W]
    W -= 1


for i in range(len(l)):
    text = ''
    for j in range(len(l[i])):
        text += l[i][j]
    print(text)

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

b=[]
d=[]
k=0
for i in range(w):
    d.append(i)

for i in range(h):
    a=input()
    if a!="."*w:
        b.append(a)
    else:
        h-=1
        
for i in range(w):
    c=0
    for j in range(h):
        if b[j][i]=="
            c+=1
    if c==0:
        del(d[k])
    else:
        k+=1
            
for i in range(h):
    for j in d:
       sys.stdout.write(b[i][j]) 
    print("")

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

row=[]
for i in range(h):
     flag=False
     for j in range(w):
         if(a[i][j]=='
             flag=True
             break
     if flag: row.append(i)
col=[]
for i in range(w):
     flag=False
     for j in range(h):
         if(a[j][i]=='
             flag=True
             break
     if flag: col.append(i)
for i in row:
    s=''
    for j in col:
        s+=a[i][j]
    print(s)

Solution (Python):


import numpy as np

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

a = np.zeros((H,W))

for h in range(H):
    line = list(input())
    
    for w in range(W):
        if line[w] == "
            line[w] = 1
        else:
            line[w] = 0
    a[h] = line


delete_line = 0
for h in range(H):
    h = h - delete_line
    if np.allclose(a[h,:], np.zeros(W)):
        a = np.delete(a, h, 0)
        delete_line += 1

delete_row = 0
for w in range(W):
    w = w - delete_row
    if np.allclose(a[:,w], np.zeros((1,H-delete_line))):
        a = np.delete(a, w, 1)
        delete_row +=  1

b = np.array(a, dtype = str)

for h in range(H-delete_line):
    for w in range(W-delete_row):
        if a[h,w] == 1:
            b[h,w] = "
        else:
            b[h,w] = "."

for i in range(H-delete_line):
    print("".join(b[i,:]))

Solution (Python):
def pri(l):
    for i in l:
        print(i)
h, w = map(int, input().split())
a, ans = [], []
for _ in range(h):
    temp = ''.join(input())
    if not all([x == '.' for x in temp]):
        a.append(temp)
for temp in [''.join(s) for s in zip(*a)]:
    if not all([x == '.' for x in temp]):
        ans.append(temp)
pri([''.join(s) for s in zip(*ans)])

Solution (Python):
import warnings
import numpy as np
warnings.simplefilter(action='ignore', category=FutureWarning)

h, w = map(int,input().split())
table = np.empty((h,w))

for i in range(h):
	temp = [0 if x=="." else 1 for x in list(input())]
	for j in range(w):
		table[i][j] = temp[j]

new1 = table


c = 0

for i in range(h):
	if not 1 in table[i]:
		new1 = np.delete(new1, i-c, 0)
		c += 1

c = 0

for j in range(w):
	if not 1 in table[:,j]:
		new1 = np.delete(new1, j-c, 1)
		c += 1

table = new1


for i in range(len(table)):
	z = ""
	for j in range(len(table[0])):	
		if table[i][j] == 0:
			z = z + "."
		else:
			z = z + "
	print(z)

Solution (Python):
H, W = map(int, input().split())
a = []
for i in range(H):
    a.append(list(input()))
for i in range(W):
    flag = True
    for j in range(H):
        if a[j][i] == '
            flag = False
    if flag:
        for k in range(H):
            a[k][i] = '-'
for i in a:
    if not '
        continue
    for j in range(W):
        if i[j] != '-':
            print(i[j], end = '')
    print('')

Solution (Python):

H,W = map(int,input().split())
b = [[0 for i in range(W)] for j in range(H)]
for i in range(0,H):
    line = input()
    for j in range(0,W):
        b[i][j] = line[j]
        

x = []
for k in range(0,H):
    flag = True
    for k2 in range(W):
        if b[k][k2] is '
            flag = False
    if flag:
        x.append(k)

y = []
for l in range(W):
    flag = True
    for m in range(H):
        if b[m][l] is '
            flag = False
    if flag:
        y.append(l)


b2 = [[0 for i in range(W-len(y))] for j in range(H-len(x))]
c1,c2 = 0,0
for i in range(H):
    c2 = 0
    if i not in x:
        for j in range(W):
            if j not in y:
                b2[c1][c2]=b[i][j]
                c2 += 1
        c1 += 1


for i in range(H-len(x)):
    s = ""
    for j in range(W-len(y)):
        s += b2[i][j]
    print(s)

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

a = []
for i in range(h):
    line = input()
    aa = []
    for j in range(len(line)):
        aa.append(line[j])
    a.append(aa)


popList = []
for i in range(len(a)):
    isBlack = False
    for j in range(len(a[i])):
        if a[i][j] == "
            isBlack = True
    
    if isBlack == False:
        popList.append(i)

for i in range(len(popList)):
    a.pop(popList[i] - i)


popList = []
for i in range(len(a[0])):
    isBlack = False
    for j in range(len(a)):
        if a[j][i] == "
            isBlack = True

    if isBlack == False:
        popList.append(i)

for i in range(len(popList)):
    for j in range(len(a)):
        a[j].pop(popList[i] - i)


for i in a:
    for j in i:
        print(j, end="")
    print()

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

h = []
w = []
for i in range(H):
    if A[i].count(".") == W:
        h.append(i)

for i in range(W):
    qwe = 0
    for j in range(H):
        if A[j][i] == ".":
            qwe += 1
        else:
            break
    if qwe == H:
        w.append(i)

p = 0
for i in h:
    A.pop(i-p)
    p += 1

p = 0
for i in w:
    i = i - p
    for j in range(len(A)):
        A[j] = A[j][:i] + A[j][i+1:]
    p += 1


for i in A:
    print(i)

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

for j, row in enumerate(a):

    tf = False
    for el in row:
        if el == '
            tf = True
    if tf is True:
        res4row.append(j)

for k, col in enumerate(a[0]):
    tf2 = False
    for row2 in a:
        if row2[k] == '
            tf2 = True
    if tf2 is True:
        res4col.append(k)

res = [[] for z in range(h)]
for num4row in res4row:
    
    for num4col in res4col:
        res[num4row].append(a[num4row][num4col])

for r in res:
    st = ''
    if len(r) != 0:
        for c in r:
            st = st + c
        print(st)

Solution (Python):
h,w=map(int,input().split())
l=[]
for i in range(h):
    l.append(list(input()))
i=0
while i<len(l):
    for j in range(len(l[0])):
        if l[i][j]!='.':
            i+=1
            break
    else:
        del(l[i])

i=0    
while i<len(l[0]):
    for j in range(len(l)):
        if  l[j][i]!='.':
            i+=1
            break
    else:
        for k in range(len(l)):
            del l[k][i]
i=0
for i in range(len(l)):
    s=''
    for j in range(len(l[0])):
        s=s+l[i][j]
    print(s)

Solution (Python):
import numpy as np

H, W = map(int, raw_input().split())
a = []
for i in range(H):
	_a = list(raw_input())
	a.append(_a)
a = np.array(a)
b = a.copy()
while True:
	r_exist = False
	c_exist = False
	for i in range(len(a)):
		if not '
			b = np.delete(a, i, 0)
			r_exist = True
	a = b.copy()
	for i in range(len(b[0])):
		if not '
			a = np.delete(b, i, 1)
			c_exist = True
	b = a.copy()
	if not (r_exist or c_exist):
		break
for i in b:
	print ('').join(i)

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

ar_true = []
for i in range(H):
    if ar[i] != ['.'*W]:
        ar_true.append(ar[i])

ar_res_line = []
n_length = len(ar_true)
for i in range(W):
    flag = False
    for ii in range(n_length):
        if ar_true[ii][0][i] == '
            flag = True
    if flag:
        ar_res_line.append(i)

ar_res = []
for h in range(n_length):
    tmp = ''
    for i in range(len(ar_res_line)):
        tmp_line = ar_res_line[i]
        tmp += ar_true[h][0][tmp_line]
    ar_res.append(tmp)

for i in range(n_length):
    print(ar_res[i])

Solution (Python):
N,M=map(int,input().split())
grid=[[0 for i in range(M)] for j in range(N)]
moji=""
for i in range(N):
    moji=input()
    for j in range(len(moji)):
        grid[i][j]=moji[j:j+1]
    

X=0
Y=0
while(X<N or Y<M): 
    delflug=True
    if (X<N):
        for i in range(M):
            if grid[X][i]=="
                delflug=False
                break
        if delflug==True:
            del grid[X]
            N-=1
            X-=1
            
        X+=1    
    else:
        for i in range(N):
            if grid[i][Y]=="
                delflug=False
                break
        if delflug==True:
            for i in range(N):
                del grid[i][Y]
                
            M-=1
            Y-=1
            
        Y+=1    
for i in range(N):
    s="".join(grid[i])
    print(s)

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


matrix_1 = []
for i in range(H):
    if matrix[i] != "." * W:
        matrix_1.append(matrix[i])


matrix_2 = []
for i in range(W):
    a = ""
    for l in range(len(matrix_1)):
        a += matrix_1[l][i]
    matrix_2.append(a)


ans = []
k = len(matrix_1)
for i in range(W):
    if matrix_2[i] != "." * k:
        ans.append(matrix_2[i])


ans_2 = []
for i in range(len(ans[0])):
    a = ""
    for l in range(len(ans)):
        a += ans[l][i]
    ans_2.append(a)


for i in range(len(ans_2)):
    print(ans_2[i])

Solution (Python):
import numpy as np

H, W = map(int, input().split())
lst = []
for _ in range(H):
    a = list(input())
    lst.append(a)
lst = np.array(lst)

for i in range(H-1, -1, -1):
    if not '
        lst = np.delete(lst, i, 0)
lst = lst.T
for i in range(W-1, -1, -1):
    if not '
        lst = np.delete(lst, i, 0)
lst = lst.T

for x in lst:
    for y in x:
        print(y, end='')
    print()

Solution (Python):
import sys

aa = input().strip().split()
h = int(aa[0])
w = int(aa[1])
a = [list(input().strip()) for _ in range(h)]
r = [list() for _ in range(2)]

for i in range(h):
    if a[i][0] == '.':
        flag = True

        for j in range(1, w):
            if a[i][j] != '.':
                flag = False
                break

        if flag:
            r[0].append(i)

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

        for j in range(1, h):
            if a[j][i] != '.':
                flag = False
                break

        if flag:
            r[1].append(i)

for i in reversed(range(len(r[0]))):
    del a[r[0][i]]

for i in reversed(range(len(r[1]))):
    for j in reversed(range(len(a))):
        del a[j][r[1][i]]

for i in range(len(a)):
    for j in range(len(a[i])):
        sys.stdout.write(a[i][j])

    sys.stdout.write('\n')

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

for i in range(len(a)):
    ct=0
    for j in range(len(a[0])):
        if a[i][j]=='
            ct+=1
    if ct!=0:
        b.append(a[i])

c=[[] for _ in range(len(b))]

for i in range(len(b[0])):
    ct=0
    for j in range(len(b)):
        if b[j][i]=='
            ct+=1
    if ct!=0:
        for k in range(len(b)):
            c[k].append(b[k][i])
            


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

Solution (Python):
import sys

def checkCol(A, i):
    for j in range(len(A[i])):
        if A[i][j] == "
            return False
    return True

def checkLow(A, j):
    for i in range(len(A)):
        if A[i][j] == "
            return False
    return True

H, W = map(int, sys.stdin.readline().strip().split(" "))

A = []
for line in sys.stdin:
    A.append(list(line.strip()))

col = []
low = []
for i in range(len(A)):
    if checkCol(A, i):
        col.append(i)

for i in range(len(A[0])):
    if checkLow(A, i):
        low.append(i)

for i, al in enumerate(A):
    if i in col:
        continue
    for j, a in enumerate(A[i]):
        if j in low:
            continue
        sys.stdout.write(a)
    sys.stdout.write("\n")

Solution (Python):
import numpy as np
H, W = map(int, input().split())
grid = np.array([list(input()) for _ in range(H)])
grid_1 = grid[~np.all(grid == '.', axis = 1), :]
grid_2 = grid_1[:, ~np.all(grid == '.', axis = 0)]
for i in range(grid_2.shape[0]):
    print(''.join(grid_2[i]))

Solution (Python):
H,W = map(int,input().split())
row_list = ['' for i in range(W)]
for i in range(H):
    line = input()
    if line == '.'*W:
        continue
    else:
        for j in range(W):
            row_list[j] = row_list[j] + line[j]
line_list = []
for i in range(W):
    if row_list[i] == '.' * len(row_list[i]):
        continue
    else:
        if line_list == []:
            for j in row_list[i]:
                line_list.append(j)
        else:
            for j in range(len(row_list[i])):
                line_list[j] = line_list[j] + row_list[i][j]
for i in line_list:
    print(i)

Solution (Python):
_in = input()
h, w = [int(i) for i in _in.split(' ')]

data = []
for i in range(h):
    _input = input()
    data.append([char for char in _input])

del_row_idx = []
for i, row in enumerate(data):
    tf = [char=='.' for char in row]
    flag = True
    for t in tf:
        flag *= t
    if flag:
        del_row_idx.append(i)

del_col_idx = []
for i in range(w):
    tf = [char=='.' for char in [row[i] for row in data]]
    flag = True
    for t in tf:
        flag *= t
    if flag:
        del_col_idx.append(i)

for idx in del_row_idx[::-1]:
    data.pop(idx)

for idx in del_col_idx[::-1]:
    for row in data:
        row.pop(idx)

for d in data:
    print(''.join(d))

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

h = 0
for i in range(H):
    inp = input()
    if inp == white:
        continue
    for j, c in enumerate(inp):
        a[j]+=c
    h+=1

b = ['' for _ in range(h)]
white = ['.' for _ in range(h)]
white = ''.join(white)

for i in range(W):
    inp = a[i]
    if inp == white:
        continue
    for j, c in enumerate(inp):
        b[j]+=c

for i in range(h):
    print(b[i])