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())
l = list()
m = 0
for i in range(h):
  c = input()
  if "
    b = [ w for w in range(len(c)) if c[w] == "
    l.append(b)
    if m < max(b) : m = max(b)
p = list()
for i in range(m) :
  for j in l:
    if i in j: break
  else:
    p.append(i)
for j in range(len(l)):
  for e in range(len(l[j])):
    cnt = 0
    for q in p:
      if l[j][e] > q : cnt += 1
    l[j][e]  = l[j][e]  - cnt
m = 0
for i in l:
  if m < max(i) : m = max(i)
for i in l:
  t = ""
  for j in range(m+1):
    if j in i : t = t + "
    else: t = t + "."
  print(t)

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

r = [False] * h
c = [False] * w

for i in range(h):
  for j in range(w):
    if a[i][j] == "
      r[i] = True
      c[j] = True

for i in range(h):
  if r[i]:
    for j in range(w):
      if c[j]:
        print(a[i][j], end="")
    print()

Solution (Python):
def adjust(array):
    
    re_array = []
    for arr in array:
        a = set(arr)
        if len(a) == 1 and ''.join(a) == '.':
            continue
        else:
            re_array.append(arr)
    return re_array


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


array = adjust(array)


array = list(zip(*array))
array = adjust(array)


array = list(zip(*array))


for arr in array:
    print(''.join(arr))

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

remove_column = []
for j in range(w):
    if len([True for v in a if v[j] == '
        remove_column.append(j)
remove_column = remove_column[::-1]

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

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

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

temp = []
for i in range(h):
    if A[i] == ['.' for _ in range(w)]:
        temp.append(i - len(temp))
h -= len(temp)
for i in temp:
    A.pop(i)

B = []
for i in range(w):
    B_row = []
    for v in A:
        B_row.append(v[i])
    B.append(B_row)

temp = []
for i in range(w):
    if B[i] == ['.' for _ in range(h)]:
        temp.append(i - len(temp))
for i in temp:
    B.pop(i)
w -= len(temp)

C = []
for i in range(h):
    C_row = []
    for v in B:
        C_row.append(v[i])
    C.append(C_row)

for r in C:
    for c in r:
        print(c, end='')
    print()

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

hc = 0
a=[]
for _ in [0]*h:
  x = list(input())
  if "
    a += [x]
    hc += 1

wc = 0
b=[]
for i in range(w):
  x = [a[k][i] for k in range(hc)]
  if "
    b += [x]
    wc += 1

for i in range(hc):
  print("".join([b[k][i] for k in range(wc)]))

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 = []
ac = [0 for i in range(w)]
for i in range(h):
    temp = list(input())
    for j in range(w):
        if temp[j] == '
            ac[j] += 1
    if '
        a.append(temp)
    else:
        h -= 1
for j in range(h):
    ans = ''
    for i in range(w):
        if ac[i] != 0:
            ans += a[j][i]
    print(ans)

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

S = []
for i in range(H):
    if T[i] == "." * W:
        continue
    else:
        S.append(list(T[i]))

m = len(S)
Z = [[] for i in range(m)]
for i in range(W):
    flag = False
    for j in range(m):
        if S[j][i] == "
            break
        if j == m - 1:
            flag = True
    if flag:
        continue
    else:
        for j in range(m):
            Z[j].append(S[j][i])

for i in range(m):
    print("".join(Z[i]))

Solution (Python):
import numpy as np
lis = []
fragone = False
fraglast = False
row,num = list(map(int,input().split()))
for i in range(row):
  lis.append(list(input()))
arr = np.array(lis)
for nikai in range(2):
  arr = arr[np.any(arr == "
  arr = arr.T
for item in arr:
  print("".join(item))

Solution (Python):
from sys import stdin

H, W = [int(i) for i in stdin.readline().rstrip().split()]
a = [stdin.readline().rstrip() for _ in range(H)]

del_row = []

for i in range(len(a)):
    all_while = True
    s = a[i]
    for c in s:
        if c == '
            all_while = False
            break
    if all_while:
        del_row.append(i - len(del_row))

for i in del_row:
    a.pop(i)

a_t = []
for col in range(W):
    s = ''
    for row in range(len(a)):
        s += a[row][col]
    a_t.append(s)

del_row = []

for i in range(len(a_t)):
    all_while = True
    s = a_t[i]
    for c in s:
        if c == '
            all_while = False
            break
    if all_while:
        del_row.append(i - len(del_row))

for i in del_row:
    a_t.pop(i)

a = []
for col in range(len(a_t[0])):
    s = ''
    for row in range(len(a_t)):
        s += a_t[row][col]
    a.append(s)

for i in a:
    print(i)

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

a = [row for row in a if not all(map(lambda i: i == ".", row))]
a_T = [col for col in zip(*a) if not all(map(lambda i: i == ".", col))]
for row in zip(*a_T):
    print("".join(row))

Solution (Python):
import numpy as np
H,W = map(int, input().split())
a = [list(input()) for i in range(H)]
sub = {".": 0, "
a = [[sub.get(x,x) for x in ai] for ai in a]
tmp = np.array(a)
tmp = tmp[:, ~(np.sum(tmp, 0) == 0)] 
tmp = tmp[~(np.sum(tmp, 1) == 0), :] 
sub2 = {0: ".", 1:"
ans = [[sub2.get(x,x) for x in tmpi] for tmpi in tmp]
for ansi in ans:
    print("{}".format("".join(ansi)))

Solution (Python):
h,w = map(int, input().split())
list_prob = []
for i in range(0,h):
    list_prob.append(list(str(input())))
i = 0
while i < h:
    
    if list_prob[i].count("
        del list_prob[i]
        h -= 1
        i -= 1
    i += 1
    


j = 0
while j < w:
    list_j = []
    for i in range(0,h):
        list_j.append(list_prob[i][j])
    if list_j.count("
        for i in range(0,h):
            del list_prob[i][j]
        w -= 1
        j -= 1
    j += 1

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

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

newGrid = []
for i in range(h):
    a = list(input())
    for j,a_j in enumerate(a):
        if a_j == "
            newGrid.append(a)
            break
        else:
            continue

ans = []
for j in range(w):
    for i in range(len(newGrid)):
        if newGrid[i][j] == "
            ans.append([newGrid[k][j] for k in range(len(newGrid))])
            break
        else:
            continue
            
for ansi in list(zip(*ans)):
    print("".join(ansi))

Solution (Python):
import numpy as np
H, W = map(int, input().split())
grid = np.array([], dtype=np.int)
for i in range(H):
    grid = np.append(grid, np.array([c=="." for c in input()]))

grid = grid.reshape(H,W)
row_test = np.where(np.sum(grid, axis=1)==W)
col_test = np.where(np.sum(grid, axis=0)==H)

grid = np.delete(grid, row_test[0], axis=0)
grid = np.delete(grid, col_test[0], axis=1)

for r in grid:
    res = ''
    for v in r:
        if v == 1:
            res += '.'
        else:
            res += '
    print(res)

Solution (Python):
H,W = map(int, input().split())
A = [input() for _ in range(H)]
ind_H = []
ind_W = []
for h,a in enumerate(A):
    if '
        ind_H.append(h)
        for w,s in enumerate(a):
            if s == '
                ind_W.append(w)
for h in ind_H:
    ans = ''
    for w in range(W):
        if w in ind_W:
            ans += A[h][w]
    print(ans)

Solution (Python):
h, w = map(int, input().split())
grid = []
for i in range(h):
  temp = list(input())
  if not temp.count('.') == w:
    grid.append(temp)

remove = []

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

for i in range(len(grid)):
  ans = ''
  for j in range(len(grid[0])):
    if not j in remove:
      ans += grid[i][j]
  
  print(ans)

Solution (Python):
h,w=map(int,input().split())
a=[input() for i in range(h)]
b=[]
d=[]
for j in range(h):
 if int('
for l in range(w):
  c=0
  for k in range(len(b)):
    if list(b[k])[l]=='
  if c!=0:d.append(l)
for m in range(len(b)):
  x=[]
  for n in d:
    x.append(b[m][n])
  x=''.join(x)
  print(x)

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


h=H
w=W
for i in range(H-1,-1,-1):
    cnt = 0    
    for j in range(W):
        if A[i][j] == ".":
            cnt += 1


    if cnt == W:
        h -= 1
        for ii in range(i, H-1):
            for jj in range(W):
                A[ii][jj] = A[ii+1][jj]

for j in range(W-1,-1,-1):
    cnt = 0    
    for i in range(h):
        if A[i][j] == ".":
            cnt += 1


    if cnt == h:
        w -= 1
        for jj in range(j, W-1):
            for ii in range(h):
                A[ii][jj] = A[ii][jj+1]

def printA(A, h, w):
    for i in range(h):
        st = ""
        for j in range(w):
            st += (A[i][j])

        print (st)    

printA(A, h, w)

Solution (Python):
h,w = map(int, raw_input().split())
m = [ raw_input() for _ in range(h) ]
hl = [ True for _ in range(h) ]
wl = [ True for _ in range(w) ]
for y in range(h):
    for x in range(w):
        if m[y][x] == '
            hl[y] = False
            wl[x] = False
for y in range(h):
    if hl[y]:
        continue
    s = ""
    for x in range(w):
        if wl[x]:
            continue
        s += m[y][x]
    print s

Solution (Python):



def main():
    h, w = map(int, input().split())
    a = []

    
    for _ in range(h):
        src = str(input())
        if len(src.replace('.', '')) > 0:
            a.append(src)

    
    blackpos = []
    for col in range(w):
        white = 0
        for row in range(len(a)):
            if a[row][col] == '.':
                white += 1
        if white != len(a):
            blackpos.append(col)

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


if __name__ == '__main__':
    main()

Solution (Python):
from itertools import compress

H, W = map(int, input().split())
grid = [input() for _ in range(H)]

nonwhiterow = [any(c == '
nonwhitecol = [any(row[i] == '

for row in compress(grid, nonwhiterow):
    comp = compress(row,  nonwhitecol)
    print(''.join(comp))

Solution (Python):

import numpy as np
h,w = map(int,input().split())
mat = []
for i in range(h):
    mat.append(list(input()))
mat = np.array(mat)

isDot = mat == '.'
y = list(np.where(np.mean(isDot,axis=0)!=1)[0])
x = list(np.where(np.mean(isDot,axis=1)!=1)[0])
output = mat[np.ix_(x,y)]
for line in output:
    print("".join(line))

Solution (Python):
"""
B - Grid Compression
ex in )
4 4

....

.

ex out)


.
"""

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

matrix = []
for h in range(H):
    line = list(input())
    
    line_num = []
    for part in line:
        line_num.append(part)
    
    matrix.append(line_num)

leave_h = []
for h in range(H):
    for w in range(W):
        
        if matrix[h][w] == "
            leave_h.append(h)
            break

leave_w = []
for w in range(W):
    for h in range(len(matrix)):
        
        
        if matrix[h][w] == "
            leave_w.append(w)
            break


for h in range(H):
    if h not in leave_h:
        continue

    for w in range(W):
        if w not in leave_w:
            continue

        print(matrix[h][w], end="")
    
    print()

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

r = [False for _ in range(h)]
for i in range(h):
    for j in range(w):
        if a[i][j] == '
            r[i] = True
            break
c = [False for _ in range(w)]
for i in range(w):
    for j in range(h):
        if a[j][i] == '
            c[i] = True
            break
for i in range(h):
    if r[i]:
        s = ""
        for j in range(w):
            if c[j]:
                s += a[i][j]
        print(s)

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

A = []
for i in range(H):
    a = input()
    if "
        
A = list(zip(*A))

B = []
for a in A:
    if "
        
B = list(zip(*B))

for b in B:
    print("".join(b))

Solution (Python):
h,w = map(int, input().split())
index1=0
listForList = []
while index1<h:
    list1 = list(input())
    if "
        listForList.append(list1)
    index1+=1

listForIndex=[]
index2 =0
while index2<w:
    index3=0
    flag =0
    while index3<len(listForList):
        if listForList[index3][index2]=="
            flag=1
        index3+=1
    if flag==0:
        listForIndex.append(index2)
    index2+=1

if len(listForIndex)>0:
    for index4 in listForIndex:
        index5=0
        while index5<len(listForList):
            listForList[index5][index4] = ""
            index5+=1

for list2 in listForList:
    print("".join(list2))

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

n_black_col = [0]*W
n_black_row = []

inp = []
for row in range(H):
    tmp = input()
    inp.append(tmp)
    r =[1 if a == "." else 0 for a in tmp]
    n_black_col = [n_black_col[i] + r[i] for i in range(W)]
    n_black_row.append(sum(r))

remove_col = []
remove_row = []
for ind, i in enumerate(n_black_col):
    if i == H:
        remove_col.append(ind)
for ind, i in enumerate(n_black_row):
    if i == W:
        remove_row.append(ind)

for i in range(H):
    if i in remove_row:
        continue
    str = ""
    for j in range(W):
        
        if j in	remove_col:
            continue
        str += inp[i][j]
    print(str)

Solution (Python):

from sys import stdin

ns = lambda: stdin.readline()[:-1] 
ni = lambda: int(stdin.readline()) 
na = lambda: list(map(int, stdin.readline().split())) 

H, W = na()
Grid = []
for _ in range(H):
    s = ns()
    if '
        Grid.append(list(s))

h = len(Grid)
res = []
for i in range(W):
    s = ''
    for j in range(h):
        s += Grid[j][i]
    if '
        res.append(s)

for i in range(len(res[0])):
    s = ''
    for j in range(len(res)):
        s += res[j][i]
    print(s)

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):
h, w = [ int(i) for i in input().split()]
grid = [list(input()) for j in range(h)]
isOkColumn = [ 0 for i in range(w)]
isOkRow = [0 for i in range(h)]

for r in range(h):
    if '
        isOkRow[r] = 1
    for c in range(w):
        if grid[r][c] == '
            isOkColumn[c] = 1

for r in range(h):
    if isOkRow[r] == 1:
        r_g = ''
        for c in range(w):
            if isOkRow[r] == 1 and isOkColumn[c] == 1:
                r_g += grid[r][c]
        print(r_g)

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

for i in range(h):
    count = 0
    for j in range(w):
        if a[i][j][0] == ".":
            count += 1
    if count == w:
        for j in range(w):
            a[i][j][1] = True

for i in range(w):
    count = 0
    for j in range(h):
        if a[j][i][0] == ".":
            count += 1
    if count == h:
        for j in range(h):
            a[j][i][1] = True

for i in a:
    flag = False
    for j in i:
        if not j[1]:
            print(j[0],end = "")
            flag = True
    if flag:
        print("")

Solution (Python):

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

M = []
for i in range(H):
	M.append(raw_input())
	
flag_list_H = []
for i in range(H):
	if '
		flag_list_H.append(True)
	else:
		flag_list_H.append(False)

flag_list_W = []
for i in range(W):
	flag = False
	for j in range(H):
		if M[j][i]=='
			flag=True
	flag_list_W.append(flag)

for i in range(H):
	if flag_list_H[i]:
		answer = ""
		for j in range(W):
			if flag_list_W[j]:
				answer+=M[i][j]
		print answer

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

row = [False]*h
column = [False]*w

for i in range(h):
  for j in range(w):
    if a[i][j] == "
      row[i] = True
      column[j] = True

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

Solution (Python):
import numpy as np
n,m = map(int,input().split())
a = list()
for i in range(n):
    a.append(list(input()))
line = np.array(a)
delete_r,delete_g=list(),list()
for i in range(n):
    if "
        delete_g.append(i)
line = np.delete(line,delete_g,0)
for i in range(m):
    if "
        delete_r.append(i)
line = np.delete(line,delete_r,1)
for i in line:
    for j in i:
        print(j,end="")
    print()

Solution (Python):
H,W=map(int,input().split())
bwmap=[]
hlist=[]
for i in range(H):
    a=input()
    if a=='.'*W:
        bwmap.append(a)
    else:
        hlist.append(i)
        bwmap.append(a)
wlist=[]
for j in range(W):
    for i in range(H):
        if bwmap[i][j]=='
            wlist.append(j)
            break
        if i==H-1:
            pass
result=[]
for i in hlist:
    res=''
    for j in wlist:
        res=res+bwmap[i][j]
    print(res)

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

goodx = [False] * h
goody = [False] * w

for i in range(h):
  for j in range(w):

    if board[i][j] == '
      goodx[i] = True
      goody[j] = True

for i in range(h):
  if goodx[i]:
    for j in range(w):
      if goody[j]:
        print(board[i][j], end='')
    print("")

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

ans = ""
for i in lines:
  ans += "".join(i) + "\n"
ans = ans[:-1]
print(ans)

Solution (Python):
import numpy as np


H, W = map(int, input().split())
lt = []

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

  
def show(mat_):
  ptn = "%s" * mat_.shape[1]
  for row in mat_:
    print(ptn % tuple(row))
    
mat = np.array(lt)

mat = mat[:, ~np.all(mat==".", axis=0)]
mat = mat[~np.all(mat==".", axis=1), :]
show(mat)

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

def trans(string, h ,w):
    m = []
    for i in range(0, w):
        m.append(string[i::w])

    return m, w, h

def cut_dot(string_list, h, w):
    m = []
    cnt = 0
    for i in range(h):
        if string_list[i].count('.') != w:
            m.append(string_list[i])
        else:
            cnt += 1
    if cnt:
        return m, h-cnt, w, True
    else:
        return m, h-cnt, w, False

for i in range(h):
    m.append(input())

loop = True
while loop:
    m, h ,w, loop = cut_dot(m,h,w)
    if loop:
        m, h, w = trans(''.join(m), h, w)
        
for i in m:
    print(i)

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





row_compressed_grid = list(filter(lambda row: any(x == "
compressed_grid = list(filter(lambda col: any(x == "

for row in zip(*compressed_grid):
    print("".join(row))

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

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

y = len(arr[0])
x = len(arr)

arr2 = [[0 for i in range(y)] for j in range(x)]

for i in range(0,x):
    if arr[i].count('
        for j in range(0,y):
            arr2[i][j]+=1

for j in range(0,y):
    f =[False]
    for i in range(0,x):
        if arr[i][j]=='
            f[0]=True
            break
    if f[0]==True:
        for i in range(0,x):
            arr2[i][j]+=1

for i in range(0,x):
    j = 0
    while((arr2[i].count(1)!=0)or(arr2[i].count(0)!=0)):
        if arr2[i][j]<2:
            del(arr[i][j])
            del(arr2[i][j])
            j -=1
        j += 1

for i in range(0,x):
    if len(arr[i])==0:
        continue
    print("".join(arr[i]))

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

w_chk = [1]*W
h_chk = [1]*H
stock = []

for i in range(H):
        grid = list(input())
        stock.append(grid)
        for j in range(W):
            if not grid[j] == '.':
                w_chk[j] *= 0
                h_chk[i] *= 0

w_chk = [i for i, x in enumerate(w_chk) if x == 0]

for i in range(H):
    if h_chk[i] == 1:
        continue
    for j in w_chk:
        print(stock[i][j], end='')
    print('\n')

Solution (Python):
def solve(h, w, a):
    rs = []
    for r in range(h):
        ok = True
        for c in range(w):
            if a[r][c] == "
                ok = False
                break
        if not ok:
            rs.append(r)
    cs = []
    for c in range(w):
        ok = True
        for r in range(h):
            if a[r][c] == "
                ok = False
                break
        if not ok:
            cs.append(c)
    res = "\n".join(map(lambda r: "".join(map(lambda c: a[r][c], cs)), rs))
    return res

assert solve(4,4,["
assert solve(3,3,["
assert solve(4,5,[".....",".....","..
h, w = map(int, raw_input().split())
a = []
for r in range(h):
    a.append(raw_input())
print solve(h, w, a)

Solution (Python):
H, W = map(int, input().split())
a = []
for i in range(H):
    a.append(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("", end = "\n")

Solution (Python):
H,W=map(int,input().split())
list = []
def isAllWhite(raw):
    for char in raw:
        if char != ".":
            return(False)
    return(True)

for i in range(H):
    raw = input()
    if isAllWhite(raw):
        continue
    else:
        list.append(raw)

def isColWhite(list,col):
    L = len(list)
    for i in range(L):
        if list[i][col] != ".":
            return(False)
    return(True)

ans = [[] for _ in range(len(list))]
for j in range(len(list[0])):
    if isColWhite(list,j):
        continue
    else:
        for i in range(len(ans)):
            ans[i].append(list[i][j])
for raw in ans:
    print("".join(raw))

Solution (Python):
h,w = map(int,input().split())
mp = [input() for i in range(h)]
mp2 = []
for i in range(h):
    if mp[i]!='.'*w:
        mp2.append(mp[i])
space = []
for i in range(w):
    flag = True
    for j in range(len(mp2)):
        flag &= (mp2[j][i]=='.')
    if flag:
        space.append(i)
for i in range(len(mp2)):
    for j in range(w):
        if j in space:
            continue
        print(mp2[i][j],end='')
    print("")

Solution (Python):
import numpy as np

H, W = list(map(int, input().split()))
arr = np.array([list(input()) for i in range(H)])
arr = arr[(np.apply_along_axis(lambda line: '
arr = arr[:, (np.apply_along_axis(lambda line: '
for l in arr.tolist():
    print(''.join(l))

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

row = [False] * h
side = [False] * w

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

for i in range(h):
    if row[i]:
        for j in range(w):
            if side[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
side = [False] * w

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

for i in range(h):
    if row[i]:
        for j in range(w):
            if side[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
side = [False] * w

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

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

Solution (Python):
from array import array
from itertools import repeat
from operator import itemgetter


def main():
    height, width = map(int, input().split())

    grid = []
    for _ in repeat(None, height):
        grid.append(array('B', (int(c == '.') for c in input())))

    for index in range(height - 1, -1, -1):
        if all(grid[index]):
            del grid[index]

    for index in range(width - 1, -1, -1):
        if all(map(itemgetter(index), grid)):
            for row in grid:
                del row[index]

    for row in grid:
        print(''.join('.' if b else '


if __name__ == '__main__':
    main()

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

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


def f1(x):
    for i in range(W):
        if A[x][i] == '
            return False
    return True


def f2(x):
    for i in range(H):
        if A[i][x] == '
            return False
    return True


ng_col = [i for i in range(H) if f1(i)]
ng_row = [i for i in range(W) if f2(i)]

for i in range(H):
    if i in ng_col:
        continue
    for j in range(W):
        if j in ng_row:
            continue
        print(A[i][j], end='')
    print()

Solution (Python):
H, W=map(int, input().split())
a=[list(input()) for _ in range(H)]
b=[[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    if '
        for j in range(W):
            b[i][j]+=1
for j in range(W):
    if any(a[i][j]=='
        for k in range(H):
            b[k][j]+=1
for i in range(H):
    for j in range(W):
        if b[i][j]==2:
            print(a[i][j], end='')
    if 2 in b[i]:
        print('')

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

isUseRow = [True] * H
isUseCol = [True] * W

for i in range(H):
    isDelete = True
    for j in range(W):
        if(a[i][j] == '
            isDelete = False
    if(isDelete == False):
        isUseRow[i] = False
for i in range(W):
    isDelete = True
    for j in range(H):
        if(a[j][i] == '
            isDelete = False
    if(isDelete == False):
        isUseCol[i] = False

for i in range(H):
    s = ''
    for j in range(W):
        if(isUseRow[i] == False and isUseCol[j] == False):
            s += a[i][j]
    if(s != ''):
        print(s)

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

H,W = inpl()
MAP = [list(input()) for i in range(H)]
xx = []
yy = []

for x in range(W):
	for y in range(H):
		if MAP[y][x] == '.':
			continue
		else:
			break
	else:
		xx.append(x)

for y in range(H):
	for x in range(W):
		if MAP[y][x] == '.':
			continue
		else:
			break
	else:
		yy.append(y)

ans = []
for y in range(H):
	if y in yy:
		continue
	tmp = []
	for x in range(W):
		if x in xx:
			continue
		tmp.append(MAP[y][x])
	ans.append(tmp)

for azu in ans:
	print(''.join(azu))

Solution (Python):


def getList(H, W, A):
    rList = [0] * H
    cList = [0] * W
    for r in range(H):
        for c in range(W):
            if A[r][c] == "
                rList[r] += 1
                cList[c] += 1
    return rList, cList

def getTargetList(tList):
    zeroList = []
    for i in range(len(tList)):
        if tList[i] == 0:
            zeroList.append(i)
    return zeroList
    
def delRow(A, tList):
    for r in reversed(tList):
        A.pop(r)
    return A

def delCol(A, tList):
    for c in reversed(tList):
        for r in range(len(A)):
            A[r].pop(c)
    return A

def solve(H, W, A):
    rList, cList = getList(H, W, A)
    A = delRow(A, getTargetList(rList))
    A = delCol(A, getTargetList(cList))
    return A
    
if __name__ == "__main__":
    H, W = map(int, input().split())
    A = []
    for i in range(H):
        tmp = input()
        A.append([])
        for s in tmp:
            A[i].append(s)

    A = solve(H, W, A)
    for i in A:
        for j in i:
            print(j, end="")
        print()

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

import numpy as np

matrix = np.empty((0, W), str)
for i in range(0, H):
    matrix = np.append(matrix, np.array([list(input())]), axis = 0)
matrix = matrix[:, np.any(matrix != ".", axis = 0)]
matrix = matrix[np.any(matrix == "
H, W = matrix.shape
for i in range(0, H):
    print(''.join(matrix[i, :]))