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):
H, W = map(int,input().split())
mapli = []
for i in range(H):
    tmp = []
    s = str(input())
    for j in range(W):
        tmp.append(s[j])
    mapli.append(tmp)

tmp = []

for i in range(H):
    count = 0
    for j in range(W):
        if mapli[i][j] == ".":
            count += 1
    if count == W:
        tmp.append(i)
tmp.sort(reverse=True)

for i in range(len(tmp)):
    del mapli[tmp[i]]

tmp = []

for i in range(W):
    count = 0 
    if mapli[0][i] == ".": 
        for j in range(len(mapli)):
            if mapli[j][i] != ".":
                break
            count += 1
    if count == len(mapli):
        tmp.append(i)
tmp.sort(reverse=True)

for i in range(len(tmp)):
    for k in range(len(mapli)):
        del mapli[k][tmp[i]]

for i in range(len(mapli)):
    print(''.join(map(str, mapli[i])))

Solution (Python):
h,w=map(int,input().split())
b=[list(input()) for _ in range(h)]
for i in range(h-1,-1,-1):
  if b[i].count('.')==w:
    del b[i]
    h-=1
for i in range(w-1,-1,-1):
  count=0
  for j in range(h):
    if b[j][i]=='.':
      count+=1
  if count==h:
    for j in range(h):
      tmp=b[j][:i]+b[j][i+1:]
      b[j]=tmp
for i in range(h):
  print(''.join(b[i]))

Solution (Python):
h,w = map(int,input().split())
hw = [list(input()) for j in range(h)]
tf = [True for i in range(w)]
ans = []
for i in hw:
  if i.count(".") != w:
    ans.append(i)
  for j in range(len(i)):
    if i[j]=="
      tf[j] = False
for i in range(len(ans)):
  for j in range(len(tf)):
    if not tf[j]:
      print(ans[i][j],end='')
  print('')

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

box = []
for i in range(H):
    a = [j for j in input()]
    if all(j == '.' for j in a):
        pass
    else:
        box.append(a)

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

for i in box:
    for j in range(len(i)):
        if j < len(i)-1:
            if j in idx:
                pass
            else:
                print(i[j], end='')
        else:
            if j in idx:
                print()
            else:
                print(i[j])

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

sharp = []
for i in range(W):
    flg = 0
    for j in range(len(a)):
        if a[j][i] == '
            flg = 1
    if flg == 1:
        sharp.append(i)

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

Solution (Python):
def main():
	H, W = map(int, input().split())
	a = [["." for _ in range(W)] for _ in range(H)]
	ans = []
	is_column_white = [True]*H
	is_row_white = [True]*W
	for i in range(H):
		row = input()
		for j in range(W):
			a[i][j] = row[j]
			if row[j] == "
				is_column_white[i]=False
				is_row_white[j] = False

	for i in range(H):
		if is_column_white[i]:
			continue
		ans_row = ""
		for j in range(W):
			if is_row_white[j]:
				continue
			ans_row += a[i][j]
		print(ans_row)

if __name__ == '__main__':
    main()

Solution (Python):
h,w=map(int,input().split())
a=[list(input()) for _ in range(h)]
ys,xs=set(),set()
for y in range(h):
	for x in range(w):
		if a[y][x] == "
			ys.add(y)
			xs.add(x)
for y in sorted(list(ys)):
	for x in sorted(list(xs)):
		print(a[y][x], end="")
	print("")

Solution (Python):
import numpy as np

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

hoge=[]
huga=[]
hago=[]
h=0
w=0
for i in range(n):
  hoge.append(list(input()))

for i in range(n):
  if(hoge[i].count("
    h+=1
    huga.append(hoge[i])
    
hoge=np.array(huga).T.tolist()

for i in range(m):
  if(hoge[i].count("
    w+=1
    hago.append(hoge[i])
    
hago=np.array(hago).T.tolist()
    
for i in range(h):
  for j in range(w):
    print(hago[i][j],end="")
  print("")

Solution (Python):


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

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



a_new = list()

for i, li  in enumerate(a):
    if a[i].count('.')  != w:
        a_new.append(a[i])

b = [list(i) for i in zip(*a_new)]


b_new = list()

for i, li  in enumerate(b):
    if b[i].count('.')  != len(b[0]):
        b_new.append(b[i])

c = [list(i) for i in zip(*b_new)]
for i in c:
    print(''.join(i))

Solution (Python):
import numpy as np

H, W = map(int, input().split())
A = np.array([list(input()) for i in range(H)])

mask = A=='.'

row_idx = np.logical_not(np.all(mask, axis=1))
col_idx = np.logical_not(np.all(mask, axis=0))

for a in A[row_idx][:, col_idx]:
    print(''.join(list(a)))

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

for h in range(H):
    a[h] = [inp for inp in input()]

check = [[0] * W for _ in range(H)]

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


final_w = [0] * W
for h in range(H):
    final_w = [final_w[w] + check[h][w] for w in range(W)]
    
final_h = [0] * H
for w in range(W):
    final_h = [final_h[h] + check[h][w] for h in range(H)]
  

for h in range(H):
    res = ''
    for w in range(W):
        if final_w[w] >= 1 and final_h[h] >= 1:
            res += a[h][w]
    print(res + '\n')

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

for i in range(H):
        bd.append(input())

x=set()
y=set()

for i in range(H):
        for j in range(W):
                if bd[i][j]=="
                        x.add(j)
                        y.add(i)
for i in y:
        for j in x:
                print(bd[i][j],end="")
        print()

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

for i in range(H):
    bd.append(input())

x = set()
y = set()
for i in range(H):
    for j in range(W):
        if bd[i][j] == '
            x.add(j)
            y.add(i)

for i in y:
    for j in x:
        print(bd[i][j], end='')
    print()

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

new_data = []
row = [0] * W
for d in data:
    if d.count('.') == W:
        continue
    new_data.append(d)
    for i in range(W):
        if d[i] == '.':
            row[i] += 1

num = len(new_data)

for d in new_data:
    for i in range(W):
        if row[i] != num:
            print(d[i], end='')
    print()

Solution (Python):
h, k = map(int, input().split())
mat = [input() for _ in range(h)]
for _  in range(2):
    poplist = []
    for i, row in enumerate(mat):
        for x in row:
            if x == '
                break
        else:
            poplist.append(i)
    poplist.reverse()
    for i in poplist:
        mat.pop(i)
    poplist = []
    mat = [x for x in zip(*mat)]
for row in mat:
    print(''.join(row))

Solution (Python):
f=lambda s:zip(*[t for t in s if'

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

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

while True:
    b=a
    for i in range(len(a)-1,-1,-1):
        if not "

    for j in range(len(a[0])-1,-1,-1):
        if all(a[i][j]=="." for i in range(len(a))):
            for i in range(len(a)):
                a[i]=a[i][:j]+a[i][j+1:]


    if b==a: break

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

Solution (Python):
import numpy as np
h, w = map(int, raw_input().split())
a = []
for i in range(h):
	tmp_a = list(raw_input())
	tmp_a = [1 if j == '
	a.append(tmp_a)
a = np.array(a)
y0, x0 = a.shape
for i in range(x0 + y0):
	a = a[np.any(a == 1, axis=1)]
	a = a[:, np.any(a == 1, axis=0)]
	y, x = a.shape
	if (x0 == x) & (y0 == y):
		break
	else:
		x0, y0 = x, y
a = a.tolist()
for i in range(y):
	ans = ['
	print ''.join(ans)

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

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

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=[]
indh=[]
indw=[]
A=[list(input()) for _ in range(H)]   
for i in reversed(range(H)):
    if set(A[i])==set('.'):
        A.pop(i)
import numpy as np
AT=list(np.array(A).T)
ansT=[]
for i in range(W):
    if set(AT[i])!=set('.'):
        ansT.append(AT[i])
for a in list(np.array(ansT).T):
    print(''.join(a))

Solution (Python):
import numpy as np
h,w = map(int,input().split())
a_list = [list(input()) for _ in range(h)]
res = []
for a in a_list:
    if set(a) != set('.'):
        res.append(a)
res = list(np.array(res).T)
resT = []
for a in res:
    if set(a) != set('.'):
        resT.append(a)
for a in list(np.array(resT).T):
    print(''.join(a))

Solution (Python):


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

delete = []
for i in range(h):
    if not("
        delete.append(i)

diff = 0
for i in range(len(delete)):
    del a[delete[i] - diff]
    diff += 1

bucket = [0] * len(a[0])
for i in range(len(a)):
    for j in range(len(a[0])):
        if a[i][j] == "
            bucket[j] += 1

delete = []
for i in range(len(bucket)):
    if bucket[i] == 0:
        delete.append(i)

diff = 0
for i in range(len(delete)):
    for j in range(len(a)):
        del a[j][delete[i] - diff]
    diff += 1

for i in range(len(a)):
    temp = "".join(a[i])
    print(temp)

Solution (Python):
H, W = map(int, input().split())
a = [input() for i in range(H)]
res = [0 for i in range(W)]
for i in range(W):
  for j in range(H):
    if a[j][i] != ".":
      break
    res[i] += 1
for i in range(H):
  if a[i][0:].count("
    for j in range(W):
      if res[j] != H:
        print(a[i][j],end="")
    print("")

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

while ('.' * w in A):
  A.remove('.' * w)

B = [''.join(col) for col in zip(*A)]

while ('.' * len(A) in B):
  B.remove('.' * len(A))


A = [''.join(col) for col in zip(*B)]

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

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

for h in range(H):
    if list[h] == '.'*W:
        del_H.append(h)

for w in range(W):
    list_C = []
    for h in range(H):
        list_C.append(list[h][w])
        if ''.join(list_C) == '.'*H:
            del_W.append(w)

list_new = []

for h in range(H):
    list_join = []
    if h in del_H:
        continue
    for w in range(W):
        if w in del_W:
            continue
        list_join.append(list[h][w])
    join_w = ''.join(list_join)
    list_new.append(join_w)

for i in list_new:
    print(i)

Solution (Python):

H,W = map(int, input().split())
a = [0 for _ in range(H)]
for i in range(H):
    a[i] = [c for c in input()]


has_black = [0 for _ in range(H)]
for i in range(H):
    if "
        has_black[i] = 1
new_a_1 = []
for i in range(H):
    if has_black[i] == 1:
        new_a_1.append(a[i])

for i in range(W):
    for j in range(len(new_a_1)):
        if new_a_1[j][i] == "
            break
    else:
        for j in range(len(new_a_1)):
            new_a_1[j][i] = ""

for string in new_a_1:
    print("".join(string))

Solution (Python):
H, W = map(int, input().split())
a = []
ans = []
ans2 = []
for i in range(H):
    a.append(input())
for i in range(H):
    if all(x == '.' for x in a[i]):
      continue
    else:
        ans.append(a[i])

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

for i in range(W):
    if all(x == '.' for x in ans[i]):
      continue
    else:
        ans2.append(ans[i])
        
ans2 = list(map(list, zip(*ans2)))    

for i in range(len(ans2)):
    for j in range(1, len(ans2[0])):
        ans2[i][0] += ans2[i][j]
    print(ans2[i][0])

Solution (Python):

import sys
import itertools
import collections
from queue import Queue
import functools
import math
import numpy as np

INF = 10**9


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

    
    ans = []
    for item in a:
        flag = False
        for v in item:
            if v == "
                flag = True
        if flag == True:
            ans.append(item)
    a = ans
    H = len(a)

    
    ans = [[] for x in range(H)]
    for i in range(W):
        flag = False
        for item in a:
            if item[i] == "
                flag = True
        if flag == True:
            for j in range(H):
                ans[j].append(a[j][i])
    for item in ans:
        print(*item, sep="")
    pass


if __name__ == '__main__':
    main()

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

while "." * w in a:
  a.remove("." * w)
hh = len(a)
  
a = ["".join(h_line) for h_line in zip(*a)]
while "." * hh in a:
  a.remove("." * hh)
    
for line in zip(*a):
  print("".join(line))

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

ls = [input() for _ in range(h)]
drops_h = []
drops_w = []

for i in range(h):
    if all([ls[i][j] == "." for j in range(w)]):
        drops_h.append(i)
    
for i in range(w):
    if all([ls[j][i] == "." for j in range(h)]):
        drops_w.append(i)

for i in range(h):
    if i in drops_h:
        continue
    else:
        for j in range(w):
            if j in drops_w:
                continue
            else:
                print(ls[i][j], end = "")
        
        print()

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

chs = {h for h in range(H) if all(a == '.' for a in ah[h])}
cws = {w for w in range(W) if all(a[w] == '.' for a in ah)}

for h in range(H):
    if h not in chs:
        print(''.join(ah[h][w] for w in range(W) if w not in cws))

Solution (Python):
def allb(S):
    for i in S:
        if not i == '.':
            return False
    return True

H,W = list(map(int,input().split()))
masu = [input() for i in range(H)]
masu = [i for i in masu if not allb(i)]
new = [[] for i in range(W)]
for i in range(len(masu)):
    for j in range(len(masu[0])):
        new[j].append(masu[i][j])
new = [i for i in new if not allb(i)]
masu = [[] for i in range(W)]
for i in range(len(new)):
    for j in range(len(new[0])):
        masu[j].append(new[i][j])
for i in masu:
    if i:
        for j in i:
            print(j,end="")
        print()

Solution (Python):
import numpy as np
H, W = map(int, input().split())
a = [list(input()) for _ in range(H)]
ans = []
for i in range(H):
    if set(a[i]) != set("."):
        ans.append(a[i])
a = list(np.array(ans).T)
ans = []
for i in range(len(a)):
    if set(a[i]) != set("."):
        ans.append(a[i])
ans = list(np.array(ans).T)
for res in ans:
    print("".join(res))

Solution (Python):
H,W = [int(x) for x in input().split()]
a = [0]*H
ng_h = []
ng_w = []
for i in range(H):
    a[i] = [1 if x == '

for i in range(H):
    if(sum(a[i]) == 0):
        ng_h.append(i)
for j in range(W):
    sumw = 0
    for i in range(H):
        sumw += a[i][j]
    if(sumw == 0):
        ng_w.append(j)


for i in range(H):
    flag = False
    for j in range(W):
        if((not i in ng_h) and (not j in ng_w)):
            flag = True
            print('
    if(flag):
        print()

Solution (Python):
H,W = list(map(int,input().split()))
a = [list(input()) for i in range(H)]
H_new = H
b = []
for h in range(H):
	judge = True
	for w in range(W):
		
		if a[h][w] != ".":
			judge = False
	if judge:
		H_new -= 1
	else:
		b.append(a[h])
c = []
W_new = W
for w in range(W):
	judge = True
	for h in range(H_new):
		if b[h][w] != ".":
			judge = False
	if judge:
		W_new -= 1
	else:
		b_new = []
		for h in range(H_new):
			b_new.append(b[h][w])
		c.append(b_new)

for h in range(H_new):
	for w in range(W_new):
		print(c[w][h],end = "")
	print("")

Solution (Python):
import numpy as np

data = input().split()

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

count = 0

i = 0
math = []
while i < h:
    x = input()
    x = list(x)
    math.append(x)
    i += 1
math = np.array(math).reshape(h,w)




i = 0 
j = 0 
while i < h:
    while j < w:
        if math[i][j] == ".":
            
            j += 1
            if j == w:
                math = np.delete(math,i,0)
                h = h-1
                i -=1
                
                
                
        else:
            break
    j = 0
    i += 1
i = 0
j = 0



while j < w:
    while i < h:
        if math[i][j] == ".":
            
            i += 1
            if i == h:
                math = np.delete(math,j,1)
                w = w-1
                j -= 1
                
                
        else:
            break
    i = 0
    j += 1
i = 0
j = 0
while i < h:
    while j < w:
        print(*math[i][j],end = "")
        j += 1
    i += 1
    j = 0
    print()

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

for i in range(h):
    if not a[i].count('
        b[i] = 0

for i in range(w):
    flag = True
    for j in range(h):
        if a[j][i] == '
            flag = False
    if flag:
        b[i + h] = 0

for i in range(h):
    for j in range(w):
        if b[i] and b[j + h]:
            print(a[i][j], end = '')
    if b[i]:
        print()

Solution (Python):
h,w = map(int,input().split())
a = [input() for i in range(h)]
removeh = []
removew = []
for i in range(h):
    if not "
        removeh.append(i)
for i in range(w):
    flag = 0
    for j in range(h):
        if a[j][i] == "
            flag = 1
            break
    if flag == 0:
        removew.append(i)

for i in range(h):
    if removeh.count(i) == 0:
        buf = ""
        for j in list(set(range(w)) - set(removew)):
            buf += a[i][j]
        print(buf)

Solution (Python):
import numpy as np

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

a = []
array = np.zeros((H,W))
for i in range(H):
    tmp = [i for i in input().split()]
    for j in range(W):
        if(tmp[0][j]=="."):
            array[i,j]=0
        else:
            array[i,j]=1


survive_h = []
survive_w = []

for i in range(H):
    if(np.sum(array[i])!=0):
        survive_h.append(i)

for i in range(W):
    if(np.sum(array[:, i])!=0):
        survive_w.append(i)

deleted_array = array[survive_h][:,survive_w]

for i in range(len(deleted_array)):
    s=""
    for j in range(len(deleted_array[0])):
        if(deleted_array[i][j]==1):
            s += "
        else:
            s += "."
    print(s)

Solution (Python):
n,m=map(int,input().split())
l=[]
for i in range(n):
  l1=list(input())
  b=True
  for j in l1:
    if j=="
      b=False
  if b==False:
    l.append(l1)
for i in range(m):
  b=True
  for j in range(len(l)):
    if l[j][m-1-i]=="
      b=False
  if b:
    for j in range(len(l)):
      del l[j][m-1-i]
for i in range(len(l)):
  print("".join(l[i]))

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

grid = []

for i in range(H):
    line = input()
    if line == '.'*W:
        continue
    grid.append(list(line))

for j in range(W):
    line = ''
    for i in range(len(grid)):
        line += grid[i][j]
    if line == '.'*len(grid):
        for i in range(len(grid)):
            grid[i][j] = '0'

for i in range(len(grid)):
    line = grid[i]
    line = ''.join(line).replace('0','')
    print(line)

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

tmp = a.copy()
for i,row in enumerate(tmp[::-1],1):
    for c in row:
        if c == "
            break
    else:
        a.pop(H-i)
tmp = len(a)
for i in range(W-1,-1,-1):
    for j in range(tmp):
        if a[j][i] == "
            break
    else:
        for j in range(tmp):
            a[j].pop(i)

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

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

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

row_deleted = [False for i in range(H)]
col_deleted = [False for i in range(W)]

for i in range(H):
    all_white = True
    for e in a[i]:
        if e != ".":
            all_white = False
    
    if all_white:
        row_deleted[i] = True
    
for i in range(W):
    all_white = True
    for j in range(H):
        if not row_deleted[j] and a[j][i] != ".":
            all_white = False
    
    if all_white:
        col_deleted[i] = True
        
for i in range(H):
    if row_deleted[i]:
        continue
    for j in range(W):
        if col_deleted[j]:
            continue
        print(a[i][j], end = '')
    print("")

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

rs = []
for a in a_s:
    if "
        rs.append(a)
ans = ["" for _ in rs]
for i in range(W):
    comp = True
    for r in rs:
        if r[i] == "
            comp = False
    if not comp:
        for j, r in enumerate(rs):
            ans[j] += r[i]

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

Solution (Python):
import numpy as np
H, W = map(int, input().split())
a = np.array([list(input()) for _ in range(H)])
row = np.all(a == '.', axis=0)
col = np.all(a == '.', axis=1)
for i in range(H):
    if col[i]:
        continue
    for j in range(W):
        if row[j]:
            continue
        print(a[i][j], end='')
    print()

Solution (Python):
h,w=map(int,input().split())
h1=[0 for i in range(h)]
w1=[0 for i in range(w)]
m=[]
for i in range(h):
  a=input()
  m+=[a]
  if not "
    h1[i]=1
    
for i in range(w):
  k=1
  for j in range(len(m)):
    if m[j][i]=="
      k=0
      break
  if k==1:
    w1[i]=1
    
for i in range(h):
  if h1[i]==1:
    continue
  ans=""
  for j in range(w):
    if w1[j]==1:
      continue
    ans+=m[i][j]
  print(ans)

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

rout = [False]*H
for i in range(H):
    for j in range(W):
        if grid[i][j] == '
            rout[i] = True
            break

cout = [False]*W
for i in range(W):
    for j in range(H):
        if grid[j][i] == '
            cout[i] = True
            break

for i in range(H):
    for j in range(W):
        if rout[i] and cout[j]:
            print(grid[i][j], end="")
    if rout[i]:
        print("")

Solution (Python):




h, w = map(int, input().split())
al = list()
wcnt = [0 for i in range(w)]
wh = h


for i in range(h):
    a = input()
    lcnt = 0
    for j in range(w):
        if a[j] == "
            wcnt[j] += 1
            lcnt += 1

    if lcnt > 0:
        al.append(a)
    else:
        wh -= 1


for i in range(wh):
    wstr = ""
    for j in range(w):
        if wcnt[j] > 0:
            wstr += al[i][j]
    print(wstr)

Solution (Python):
h,w=map(int,input().split());b=[input()for i in range(h)];a=[]
for i in b:
  if i!="."*w:a.insert(0,i)
b=[]
for i in range(w):
  s=""
  for j in a:s=j[i]+s
  if s!="."*len(a):b.insert(0,s)
c=[]
for i in range(len(a)):
  s=""
  for j in b:
    s=j[i]+s
  print(s)

Solution (Python):
a,b=map(int,input().split())
l=[]
for i in range(a):
    s=input()
    if set(s)=={"."}:
        continue
    else:
        l.append(s)

r=""
l2=[]
for i in range(b):
    for t in range(len(l)):
        r+=l[t][i]

    if set(r)!={"."}:
        l2.append(r)
    r=""
g=""

for i in range(len(l2[0])):
    for t in l2:
        g+=t[i]
    print(g)
    g=""

Solution (Python):
H,W = map(int,input().split())
grid = []
for h in range(H):
    a = input()
    if '
        grid.append(a)

white = set() 
for w in range(W):
    if all(l[w] == '.' for l in grid): 
        white.add(w)

for l in grid:
    print("".join(l[w] for w in range(W) if w not in white))

Solution (Python):
from numpy import*
h,w=int8(input().split())
a=array(eval('list(input()),'*h))
print(*map(''.join,a[any(a<'.',1)][:,any(a<'.',0)]))

Solution (Python):
import numpy as np
from sys import stdin
H,W=[int(x) for x in stdin.readline().rstrip().split()]
data=[]
for i in range(H):
    data.append([ 1 if x == "
data=np.array(data)
index_col=[]
for j in range(W):
    if sum(data[:,j]) == 0:
        index_col.append(j)
data=np.delete(data, index_col, 1)

index_row=[]
for k in range(H):
    if sum(data[k]) == 0:
        index_row.append(k)
data=np.delete(data,index_row,0)
for l in data:
    tmp=""
    for m in l:
        if m == 1:
            tmp=tmp+"
        else:
            tmp=tmp+"."
    print(tmp)

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

list_grid = []
for i in range(H):
  list_grid.extend(list(input().split()))


for i, record in enumerate(list_grid):
  if record == '.' * W:
    list_grid[i] = ''

list_grid = list(filter(lambda s:len(s)>0, list_grid))

import copy
ans = copy.copy(list_grid)


row = 0
flg = True
while flg:
  tmp = []
  for record in ans:
    tmp.append(record[row])
  
  
  if not ('
    for i in range(len(ans)):     
      ans[i] = ans[i][:row] + ans[i][row+1:]
  else:
    row += 1
      
  if row == len(ans[0]):
    flg = False



for record in ans:
  print(record)

Solution (Python):

h, w = map(int, input().split())
h1 = [0]*h
w1 = [0]*w

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

for i in range(h):
    for j in range(w):
        if(a[i][j]=='
            h1[i] = 1
            w1[j] = 1

for i in range(h):
    if h1[i]==1:
        for j in range(w):
            if(w1[j]==1):
                print(a[i][j], end='')
        print()

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

grid = []
for h in range(H):
    a = input()
    if '
        grid.append(a)

white = set()
for w in range(W):
    if all(l[w] == '.' for l in grid):
        white.add(w)

H = len(grid)

for l in grid:
    print("".join(l[w] for w in range(W) if w not in white))

Solution (Python):
from sys import stdin
h,w = [int(x) for x in stdin.readline().rstrip().split()]
data = [stdin.readline().rstrip() for _ in range(h)]
row=[False]*h
col=[False]*w
for i,r in enumerate(data):
    for j,c in enumerate(r):
        if c=='
            row[i]=True
            col[j]=True
for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(data[i][j],end='')
        print()

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

l = []
for i in range(H):
  line = input()
  if "
    l.append(line)
  else:
    H -= 1

to_be_deleted = []
for i in range(W):
  white = True
  for line in l:
    if line[i] == "
      white = False
      break
  if white:
    to_be_deleted.append(i)
    
for i in to_be_deleted[::-1]:
  for j in range(H):
    if i < W-1:
      l[j] = l[j][:i] + l[j][i+1:]
    else:
      l[j] = l[j][:i]
      
for item in l:
  print(item)

Solution (Python):
import numpy as np
H, W = map(int, input().split())
a = np.array([list(input()) for _ in range(H)])

row_ind = np.where(np.all(a==['.']*(np.shape(a)[1]) ,axis=1))
a = np.delete(a, row_ind, axis=0)

col_ind = np.where(np.all(a==[['.']]*(np.shape(a)[0]), axis=0))
a = np.delete(a, col_ind, axis=1)

for i in range(np.shape(a)[0]):
    print(''.join(a[i,:]))

Solution (Python):
h, w = map(int, input().split())
a = []
for i in range(h):
    a.append([i for i in input()])
h_count = []
for h_ in range(h):
    if a[h_] == ["."] * w:
        h_count.append(h_)
w_count = []
for w_ in range(w):
    if list(map(lambda x: x[w_], a)) == ["."] * h:
        w_count.append(w_)
h_get = [i for i in range(h) if i not in h_count]
w_get = [i for i in range(w) if i not in w_count]

for i in h_get:
    temp = a[i]
    temp_1 = []
    for j in w_get:
        temp_1.append(temp[j])
    print("".join(temp_1))

Solution (Python):
h,w=map(int,input().split())
grid=[]
grid2=[]
grid3=[]
for i in range(h):
  grid.append(list(input().replace(" ","")))
for i in range(len(grid)):
  if grid[i].count('.')==len(grid[i]):
    pass
  else:
    grid2.append(grid[i])
for i in grid2:
  grid3.append([])
for j in range(len(grid2[0])):
  for i in range(len(grid2)):
    if grid2[i][j]=='
      for k in range(len(grid3)):
        grid3[k].append(grid2[k][j])
      break
for i in grid3:
  print(''.join(i))

Solution (Python):
h,w=map(int,input().split())
point=[0]*w
a=[]
for _ in range(h):
    x=input()
    if x.count("
        a.append(x)
        for i in range(w):
            if x[i]=="
                point[i]+=1
for k in range(len(a)):
    s=a[k]
    ans=""
    for j in range(w):
        if point[j]!=0:
            ans+=s[j]
    print(ans)

Solution (Python):
import numpy as np
h,w=map(int,input().split())
a=[list(map(int,input().replace(".","0").replace("
a=np.array(a)
c=np.sum(a,axis=1)
a=a[c!=0]
c=np.sum(a,axis=0)
a=a.T[c!=0].T
for i in a.tolist():
    tmp=list((map(lambda x:"." if x==0 else "
    print("".join(tmp))

Solution (Python):
h, w = map(int, input().split())
a = [input() for i in range(h)]
b = [['0']*w for i in range(h)]
for i in range(w):
    cnt = 0
    for j in range(h):
        if a[j][i] == '.':
            cnt += 1
    if cnt != h:
        for p in range(h):
            b[p][i] = a[p][i]
for i in range(len(b)):
    b[i] = [j for j in b[i] if j != '0']
for i in b:
    if ''.join(i) != '.'*len(i):
        print(''.join(i))

Solution (Python):
H,W=map(int,input().split())
m=[]
for _ in[0]*H:
  l=input()
  if l!='.'*W:m+=[l]
t=[]
for j in range(W):
  f=0
  for l in m:
    if l[j]!='.':f=1;break
  if f:t+=[j]
for l in m:
  print("".join([l[j] for j in t]))

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

row = []
for i in a:
    if i == '.' * W:
        continue
    row.append(i)

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

for i in range(len(row)):
    for j in column:
        print(row[i][j], end="")
    print('\n')

Solution (Python):
H, W = map(int, input().split())
box = []
for i in range(H):
    A = input()
    if not "
        continue
    box.append(A)
box_t = []
for i in range(W):
    X = ""
    for j in range(len(box)):
        X += box[j][i]
    if not "
        continue
    box_t.append(X)
for i in range(len(box_t[0])):
    for j in range(len(box_t)):
        print(box_t[j][i], end="")
    if i == len(box_t[0]) - 1:
        break
    print()

Solution (Python):
f=lambda s:zip(*[t for t in s if'