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 numpy as np

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

l = [];
for i in range(H):
	r = input()
	if set(r) != {'.'}:
		k = list(r)
		l.append(k)

d = []
for i in range(W):
	p = [[j[i]] for j in l]
	result = []
	for sublist in p:
	    for item in sublist:
	        result.append(item)
	if set(result) == {'.'}:
		d.append(i)

nl = np.array(l)
itr = 0
for x in range(len(d)):
	nl = np.delete(nl, d[x]-itr, 1)
	itr += 1

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

Solution (Python):
import sys
from collections import deque
import copy

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [H, W] = [int(input_raw[0]), int(input_raw[1])]
    field = []
    for i in range(H):
        input_raw = read_func().strip().split()
        field.append(input_raw[0])
    is_all_white_raw = [True for i in range(H)]
    is_all_white_col = [True for i in range(W)]

    for i in range(H):
        for j in range(W):
            if field[i][j] == "
                is_all_white_raw[i] = False
                break

    for j in range(W):
        for i in range(H):
            if field[i][j] == "
                is_all_white_col[j] = False
                break

    for i in range(H):
        if is_all_white_raw[i] == True:
            continue
        for j in range(W):
            if is_all_white_col[j] == True:
                continue
            sys.stdout.write(field[i][j])
        print

if __name__ == '__main__':
    main()

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

rows = []
for i in range(1,H+1):
    row = input()
    if row.count("
        rows.append(list(row))

cols = []
for j in range(W):
    col = ""
    for k in range(len(rows)):
        col += rows[k][j]

    if col.count("
        cols.append(col)
        
ans = []
for l in range(len(cols[0])):
    row = ""
    for m in range(len(cols)):
        row += cols[m][l]

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

Solution (Python):


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

a = []
for i in range(0,H):
    data = str(input())
    a.append(list(data))

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

for i in range(W-1,-1,-1):
    check = 0
    for j in range(0,int(len(a))):
        if a[j][i] == "
            check = 1
            break
        else:
            pass
    if check == 0:
        for j in range(0,int(len(a))):
            del a[j][i]

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

Solution (Python):
na = lambda: list(map(int, input().split()))

h, w = na()
t = []
cnt = 0
for i in range(h):
    I = list(input())
    if not("
        cnt += 1
        continue
    t.append(I)
output = []
for j in range(w):
    flag = False
    for i in range(h-cnt):
        if t[i][j] == "
            flag = True
    if flag:
        output.append(j)
for T in t:
    for num, i in enumerate(T):
        if num in output:
            print(i, end="")
    print()

Solution (Python):


INF = float('inf')


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


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

comp = []
for i in range(h):
    for j in range(w):
        if A[i][j] == '
            comp.append([1 for _ in range(w)])
            break
    else:
        comp.append([0 for _ in range(w)])

B = list(zip(*A))[:]
comp = list(zip(*comp))[:]
for i in range(w):
    for j in range(h):
        if B[i][j] == '
            
            break
    else:
        comp[i] = [0 for _ in range(h)]

comp = list(zip(*comp))[:]


ans = []
for i in range(h):
    tmp = []
    for j in range(w):
        if comp[i][j] == 1: tmp.append(A[i][j])
    if tmp != []:
        ans.append(tmp)


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

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

for w in range(W):
    t = []
    for h in range(H):
        t.append((L[h][w]))
    
    if '
        for h in range(H):
            L[h][w] = ""
            
for l in L:
    if "
        pass
    else:
        res.append(l)

for i in res:
    result = ''
    for j in i:
        result += j
    print(result)

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

for i in range(H):
    for j in range(W):
        if a[i][j] == '
            a_new.append(a[i])
            break

a_ = list(zip(*a_new))
a_H  = len(a_)
a_W  = len(a_[0])

for i in range(a_H):
    for j in range(a_W):
        if a_[i][j] == '
            a_new_new.append(a_[i])
            break
 
for i in list(zip(*a_new_new)):
    print(''.join(i))

Solution (Python):
import numpy as np
H,W=map(int,input().split(" "))

def white(a):
    ans=0
    for i in range(len(a)):
        if a[i]=="
            ans=1
    return ans

A=[]
for i in range(H):
    gyo=list(input())
    if white(gyo)==1:
        A.append(gyo)

Anum=np.array(A)
ash=Anum.shape[1]
for i in range(ash):
    j=ash-i-1
    if white(Anum[:,j])==0:
        Anum=np.delete(Anum,j,1)

for i in range(Anum.shape[0]):
    moji=""
    for j in range(Anum.shape[1]):
        moji+=Anum[i,j]        
    print(moji)

Solution (Python):


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

mtrx = []

for i in range(H):
    inputstr = input()
    if '
        mtrx.append(list(inputstr))

trv_mtrx = list(map(list, zip(*mtrx)))

new_mtrx = []

for line in trv_mtrx:
    if '
        new_mtrx.append(line)

for l in list(map(list,zip(*new_mtrx))):
    print(''.join(l))

Solution (Python):

"""
Created on Sat Aug 25 18:21:29 2018
ABC107B
@author: maezawa
"""

h, w = list(map(int, input().split()))
lattice = []
for i in range(h):
    hi = input()
    if '
        continue
    else:
        lattice.append(hi)



hn = len(lattice)
rem = []
for i in range(w):
    flag = 0
    for s in lattice:
        if s[i] == '
            flag = 1
            break
    if flag == 0:
        rem.append(i)
        
newlattice = []

for s in lattice:
    for i in reversed(range(w)):
        if i in rem:
            if i == w:
                s = s[:i]
            else:
                s = s[:i]+s[i+1:]
    newlattice.append(s)

for s in newlattice:
    print(s)

Solution (Python):
h, w = map(int, input().split())
graph = [[0 for _ in range(w)] for _ in range(h)]
ans_graph = []
for i in range(h):
  w_g = input()
  for j in range(w):
    graph[i][j] = w_g[j]

pop_row_list = []
pop_ar_list = []
for i in range(h):
  flag = True
  for j in range(w):
    if graph[i][j] != '.':
      flag = False
  if flag == True:
    pop_row_list.append(i)

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

ans_graph = []

for i in range(h):
  if i in pop_row_list:
    continue
  ans_graph.append([])
  for j in range(w):
    if j in pop_ar_list:
      continue
    ans_graph[-1].append(graph[i][j])

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

Solution (Python):
import numpy as np

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

A = [["" for i in range(W)] for j in range(H)]

for i in range(H):
    tmp = list(input())
    for j in range(W):
        A[i][j] = tmp[j]

hlist = []
wlist = []

for i in range(H):
    if "
        hlist.append(i)

for j in range(W):
    tmp = []
    for i in range(H):
        tmp.append(A[i][j])
    if "
        wlist.append(j)




for i in hlist:
    for j in range(W):
        A[i][j] = 0

for j in wlist:
    for i in range(H):
        A[i][j] = 0

for i in range(H):
    while True:
        if 0 in A[i]:
            A[i].remove(0)
        else:
            break

while True:
    if [] in A:
        A.remove([])
    else:
        break

for li in A:
    print("".join(li))

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


yoko = []
for i in range(h):
    judge = True
    for j in range(w):
        if a[i][j] == "
            judge = False
            break
    if judge:
        yoko.append(i)
tate = []
for i in range(w):
    judge = True
    for j in range(h):
        if a[j][i] == "
            judge = False
            break
    if judge:
        tate.append(i)

it = 0
iy = 0
an = [[] for i in range(h-len(yoko))]

for i in range(h):
    sum = 0
    for j in range(w):
        if i not in yoko and j not in tate:
            print(a[i][j], end="")
            sum += 1
    if sum != 0:
        print("")

Solution (Python):
a,b = [int(i) for i in input().split()]

import numpy as np
n = []

for i in range(a):
    buf = list(input())
    if "
        n.append(buf)

buffer = []
for i in range(len(n)):
    for j in range(b):
        if "
            buffer.append(j)

buffer = list(set(buffer))

for i in range(len(n)):
    joined = [n[i][j] for j in buffer]
    print("".join(joined))

Solution (Python):
a,b=map(int,input().split(" "))
l=[]
for i in range(a):
    k=list(input())
    l.append(k)
ca=0
for i in range(a):
    for j in range(b):
        if l[i-ca][j]=="." and j+1==b:
            del l[i-ca]
            ca+=1
        elif l[i-ca][j]=="." :
            pass
        else:
            break
cb=0
for i in range(b):
    for j in range(a-ca):
        if l[j][i-cb]=="." and j+1==a-ca:
            for k in range(a-ca):
                del l[k][i-cb]
            else:
                cb+=1
        elif l[j][i-cb]==".":
            pass
        else:
            break
        
for i in l:
    print(*i,sep="")

Solution (Python):
import numpy as np
H, W = map(int, raw_input().split())
grids = []
for i in xrange(H):
  grids.append(raw_input())
  
grid_num = []
for grid in grids:
  grid_num.append(map(lambda x: 1 if x == '
  
grid_num = np.array(grid_num)

comp_grid_num = []
for w in xrange(W):
  if grid_num[:, w].any():
    comp_grid_num.append(grid_num[:, w])

comp_grid_num = np.array(comp_grid_num)
comp_grid = ""
for h in xrange(H):
  if comp_grid_num[:, h].any():
    comp_grid += "".join(map(lambda x: '
    
print comp_grid

Solution (Python):
n,m = map(int,input().split())
lis = []
for i in range(n):
  lis.append(str(input()))
tate = [0]*n
yoko = [0]*m
for k in range(n):
  for h in range(m):
    if lis[k][h] == "
      tate[k] = 1
      yoko[h] = 1
li = []
cou = n
for i in range(n):
  s = []
  for k in range(m):
    if tate[i] != 0 and yoko[k] != 0:s.append(lis[i][k])
  if s == []:
    cou -= 1
  else:
    li.append(s)
for i in range(cou):print("".join(li[i]))

Solution (Python):



H, W = map(int,input().split())
moto = []
for i in range(H):
    moto.append(list(input()))
for i in range(H):
    j = 0
    while moto[H-i-1][j] == ".":
        if j == W-1:
            moto.pop(H-i-1)
            break
        j += 1

for i in range(W):
    j = 0
    while moto[j][W-i-1] == ".":
        if j == len(moto)-1:
            for k in range(len(moto)):
                moto[k].pop(W-i-1)
            break
        j += 1
for i in range(len(moto)):
    for j in range(len(moto[0])-1):
        print(moto[i][j],end="")
    print(moto[i][len(moto[0])-1])

Solution (Python):
import numpy as np

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

board = []
arr = np.empty((0,W),str)

for i in range(H):
  string = list(str(input()))
  board.append(string)
  arr = np.append(arr, np.array([string]), axis=0)

delete_h = []
delete_w = []
for i in range(H):
  cc = 0
  for j in range(W):
    if board[i][j] == "
      cc += 1
  if cc == 0:
    delete_w.append(i)

for i in range(W):
  cc = 0
  for j in range(H):
    if board[j][i] == "
      cc += 1
  if cc == 0:
    delete_h.append(i)
    
delete_w.reverse()
delete_h.reverse()

for i in delete_h:
  arr = np.delete(arr, i, 1)

for i in delete_w:
  arr = np.delete(arr, i, 0)

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

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

del_lst = []

for i in range(H):
  for j in range(W):
    if a[i][j] == '
      break
  else:
    del_lst.append(i)


for i in sorted(del_lst,reverse=True):
  a.pop(i)


del_lst = []
for i in range(len(a[0])):
  for j in range(len(a)):
    if a[j][i] == '
      break
  else:
    del_lst.append(i)


for i in sorted(del_lst,reverse=True):
  for j in range(len(a)):
    str = list(a[j])
    str.pop(i)
    a[j] = ''.join(str)

for _a in a:
  print(_a)

Solution (Python):
import numpy as np

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

A = np.empty((H, W), dtype='str')
for i in range(H):
    A[i, :] = list(input())


def delete_row(A):
    nrow = A.shape[0]
    ncol = A.shape[1]

    idx = []
    for i in range(nrow):
        if (''.join(A[i, :]) != '.'*ncol):
            idx.append(i)
    return(A[idx, :])


def delete_col(A):
    nrow = A.shape[0]
    ncol = A.shape[1]

    idx = []
    for i in range(ncol):
        if (''.join(A[:, i]) != '.'*nrow):
            idx.append(i)
    return(A[:, idx])

while(True):
    nrow, ncol = A.shape
    A = delete_row(A)
    A = delete_col(A)
    nrow_, ncol_ = A.shape
    if (nrow_ == nrow and ncol_ == ncol):
        break

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

Solution (Python):



def main():
    h, w = list(map(int, input().split()))
    removed = list()

    for i in range(h):
        ai = input()

        if ai.count('.') != w:
            removed.append(ai)

    ans = list()
    count = 0

    for j in range(len(removed[0])):
        is_black = False

        for i in range(len(removed)):
            if removed[i][j] == '
                is_black = True

        if is_black:
            for i in range(len(removed)):
                ans.append(removed[i][j])

            count += 1

    for m in range(len(ans) // count):
        result = ''

        for k in range(m, len(ans), len(ans) // count):
            result += ans[k]

        print(result)


if __name__ == '__main__':
    main()

Solution (Python):
h,w=map(int,input().split())
s=[]
l=set()
for i in range(h):
  a=list(input())
  if set(a) != set("."):
    s.append(a)
    for j in range(w):
      if a[j]=="
        l|={j}
for i in s:
  p=""
  for j in sorted(list(l)):
    p+=i[j]
  print(p)

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

for _ in range(0, h):
    grid.append(input())

while True:
    modified = False

    for i in range(0, h):
        if all(True if grid[i][j] == "." else False for j in range(0, w)):
            del grid[i]

            modified = True
            h       -= 1

            break

    for j in range(0, w):
        if all(True if grid[i][j] == "." else False for i in range(0, h)):
            for i in range(0, h):
                grid[i] = grid[i][0:j] + grid[i][j + 1:]

            modified = True
            w       -= 1

            break

    if not modified:
        break

for r in grid:
    print(r)

Solution (Python):




import copy

def check_w(in_l):
    l = copy.deepcopy(in_l)
    for i in range(len(l)):
        line = list(l[i])
        
        if '
            
            del l[i]
            return l, True
    return l, False


def check_h(in_l):
    l = copy.deepcopy(in_l)
    
    
    for i in range(len(l[0])):
        line = [ l[j][i:i+1] for j in range(len(l))]
        
        if '
            ret = []
            
            for j in range(len(l)):
                ret.append(l[j][:i] + l[j][i+1:])
            return ret, True
    return l, False
            
    
def main(in_l):
    l = copy.deepcopy(in_l)
    flg = True
    
    
    while flg:
        
        ret_l, ret_f = check_w(l)
        if ret_f:
            l = ret_l
            flg = True
            continue
        else:
            flg = False

        ret_l, ret_f = check_h(l)
        if ret_f:
            l = ret_l
            flg = True
            continue
        else:
            flg = False

    
    for line in l:
        print('{}'.format(line))
    
    
if __name__ == '__main__':
    try:
        h, w = list(map(int,input().strip().split(" ")))
        l = []
        for _ in range(h):
            l.append(input().strip())
        main(l)
    except EOFError:
        pass

Solution (Python):
import numpy as np
H, W = map(int, input().split())
a_list = []
for i in range(H):
    a_list.append(list(map(str, input().split())))
dot = '....................................................................................................'

a_list2 = []
for i in range(H):
    if a_list[i] != [dot[0:W]]:
        a_list2.append([c for c in a_list[i][0]])

a_list3 = []
for i in range(len(a_list2[0])):
    if ''.join(list(np.array(a_list2)[:,i])) != dot[0:len(a_list2)]:
        a_list3.append(list(np.array(a_list2)[:,i]))

for i in range(len(a_list3[0])):
    print(''.join(list(np.array(a_list3).T[i,:])))

Solution (Python):
h, w = map(int, input().split())
ma = []
s = 0
for i in range(h):
    k = []
    k += input()
    if k.count("
        ma.append(k)
        s += 1
q = []
for i in range(w):
    for j in range(s):
        if ma[j][i] == "
            break
    else:
        q.append(i)
for i in range(len(q)):
    for j in range(s):
        del ma[j][q[-(i+1)]]
for i in range(s):
    print("".join(ma[i]))

Solution (Python):
import numpy as np

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

tmp=[]
for i in range(H):
    if np.sum(a[i])==0:
        tmp.append(i)
a = np.delete(a,tmp,0)

h=len(tmp)

a = a.T

tmp=[]
for i in range(W):
    if np.sum(a[i])==0:
        tmp.append(i)
a = np.delete(a,tmp,0)
               
a = a.T

w = len(tmp)

ans = list(a)

for i in range(H-h):
    tmp=a[i]
    for j in range(W-w):
        if tmp[j] == 1:
            print("
        else:
            print(".", end="")
    print()

Solution (Python):
from operator import itemgetter

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

A = []
Hnew = 0
for i in range(H):
    temp = input()
    if temp == '.' * W:
        pass
    else:
        A.append(temp)
        Hnew += 1

FlagA = [0] * W

for i in range(W):
    for j in range(Hnew):
        if A[j][i] == '
            FlagA[i] = 1
            break

for i in range(Hnew):
    for j in range(W):
        if FlagA[j] == 1:
            print(A[i][j], end="")
    print()

Solution (Python):
H, W = map(int, input().split())
a = []
for i in range(H):
    b = input()
    if "
        a.append(b)
field = []
for j in range(W):
    c = ''
    for k in range(len(a)):
        c += a[k][j]
    if "
        field.append(c)

length = len(field[0])
result = []
for k in range(length):
    newfield = ''
    for l in range(len(field)):
        newfield += field[l][k]
    print(newfield)

Solution (Python):
H, W = map(int, input().split())
M = []
for i in range(H):
    L = list(input())
    if '
        M.append(L)
Mt = list(map(list, zip(*M)))
A = []
for i in range(W):
    L = Mt[i]
    if '
        A.append(L)
ans = list(map(list, zip(*A)))
for i in range(len(ans)):
    L = ans[i]
    print("".join(L))

Solution (Python):

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

for i in range(H):
    aij.append( list(input()) )



ans = []
for i in range(H):
    if aij[i] == ['.']*W:
        continue
    else:
        ans.append(aij[i])

pop_num = []
for j in range(W):
    tmp = []
    for i in range(len(ans)):
        tmp.append(ans[i][j])
    if tmp == ['.']*len(ans):
        for i in range(len(ans)):
            pop_num.append(j)

ans2 = []
for i in range(len(ans)):
    tmp = []
    for j in range(W):
        if j not in pop_num:
            tmp.append(ans[i][j])
    ans2.append(tmp)

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

Solution (Python):


h,w=map(int,input().split())
l=["" for i in range(w)]
yo=[]
for i in range(h):
    s=input()
    for a,j in enumerate(s):
        l[a]+=j
for i in l:
    if "
        yo.append(i)
x=len(yo[0])
ans=["" for i in range(x)]
for i in yo:
    for a,j in enumerate(i):
        ans[a]+=j
for i in ans:
    if "

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

rm = []

for i in range(H):
    if "
        for j in range(W):
            rm.append([i,j])

for i in range(W):
    t = []
    for k in range(H):
        t.append(a[k][i])
    if "
        for j in range(H):
            rm.append([j,i])


aa = []
for i in range(H):
    t = []
    for j in range(W):
        if [i,j] not in rm:
            t.append(a[i][j])
    if len(t) != 0 :
        aa.append(t)


for i in range(len(aa)):
    for j in range(len(aa[i])):
        print(aa[i][j],end="")
    print("")

Solution (Python):
H, W = map(int,input().split())
map = [[str(i) for i in input()] for j in range(H)]
delList1 = []
delList2 = []
for k in range(H):
    if "
        delList1.append(k)

for l in reversed(delList1):
    del map[l]

for m in range(W):
    if "
        delList2.append(m)

for o in reversed(delList2):
    for p in range(len(map)):
        map[p].pop(o)

for q in map:
    print("".join(q))

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

while True:
    for i in range(0, h):
        if all([a[i][j]=='.' for j in range(0, w)]):
            del a[i]
            h -= 1
            break
    else:
        for j in range(0, w):
            if all([a[i][j]=='.' for i in range(0, h)]):
                for i in range(0, h):
                    a[i] = a[i][:j] + a[i][j+1:]
                w -= 1
                break
        else:
            for k in range(0, h):
                print(a[k])
            exit()

Solution (Python):
H,W = map(int,input().split())
def trans(x):
    if x == '.':
        return False
    else:
        return True
a = []
for i in range(H):
    v = input()
    if v == '.'*W:
        H -= 1
    else:
        a.append(v)
test = [True for j in range(W)]
d = 0
for i in range(H):
    test = [True if test[j] and a[i][j] == '.' else False for j in range(W)]
for j in range(W):
    if test[j]:
        a = [a[i][:(j-d)]+a[i][(j-d+1):] for i in range(H)]
        d += 1
for i in range(H):
    print(a[i])

Solution (Python):
tateN, YokoN = map(int,input().split())
arr = [input() for i in range(tateN)]


tateline = list()
for i in range(0, tateN):
    if arr[i].find('
        tateline.append(i)

yokoline = list()
for j in range(0, YokoN):
    found = False
    for tate in range(0, tateN):
        if arr[tate][j] == '
    if found : yokoline.append(j)

for t in tateline:
    prstr = ''
    for y in yokoline:
        prstr += arr[t][y]
    print(prstr)

Solution (Python):

h,w = map(int,input().split())
li = []
del_r = []
del_c = []
for i in range(h):
    li.append(list(input()))
    
    
    for j in range(w):
        if li[i][j] == '
            break
            
        if li[i][j] == '.' and j == w-1:
            del_r.append(int(i))

for j in range(w):
    for i in range(h):
        if li[i][j] == '
            break
        if li[i][j] == '.' and i == h-1:
            del_c.append(int(j))
            



for i in range(h):
    if i in del_r:
        continue
    for j in range(w):
        if j in del_c:
            continue
        print(li[i][j], end="")
    print("")

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

hlist = []
for i in range(0,h):
    for j in range(1,w):
        if a[i][j-1] !=  a[i][j]:
            break
        if j == w-1 and a[i][j] == ".":
            hlist.append(i)
wlist = []
for j in range(0,w):
    for i in range(1,h):
        if a[i-1][j] !=  a[i][j]:
            break
        if i == h-1 and a[i][j] == ".":
            wlist.append(j)

b = 0
for i in hlist:
    a.pop(i-b)
    b += 1
    h -= 1
b = 0
for j in wlist:
    for i in range(0,h):
        a[i].pop(j-b)
    b += 1
    w -= 1

for i in range(0,h):
    for j in range(0,w):
        if j < w-1:
            print(a[i][j],end="")
        else:
            print(a[i][j])

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

a = []

for i in range(h):
	b = input()
	if b.count('.') != m:
		a.append(b)

b = len(a)
c =['' for i in range(m)]

for i in a:
	for j in range(m):
		c[j] += i[j]
d = []
for i in c:
	if i.count('.') != len(i):
		d.append(i)

b = len(d)
c =['' for i in range(len(d[0]))]

for i in d:
	for j in range(len(d[0])):
		c[j] += i[j]

for i in c:
	print(i)

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

for i in range(0, H):
    temp = list(input())
    grid.append(temp)

yoko = []
tate = []
for i in range(0, H):
    judge = True
    for j in range(0, W):
        if grid[i][j] != '.':
            judge = False
    if judge:
        yoko.append(i)
        
for i in range(0, W):
    judge = True
    for j in range(0, H):
        if grid[j][i] != '.':
            judge = False
    if judge:
        tate.append(i)


for i in range(0, H):
    for j in range(0, W):
        if i in yoko or j in tate:
            pass
        else:
            print(grid[i][j], end='')
    if not i in yoko:
        print('')

Solution (Python):


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

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

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

for j in range(w - 1, -1, -1):
    flg = True
    for i in range(len(a)):
        if a[i][j] == "
            flg = False
            break

    if flg:
        for i in range(len(a)):
            del(a[i][j])

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

Solution (Python):
import sys
sdin = sys.stdin.readline

h,w = map(int, sdin().split())
field = []
for hi in range(h):
    field.append(sdin())
    
f2 = []
for hi in range(h):
    if field[hi].count("
        f2.append(field[hi])
    
f2_char = [list(f2[hi]) for hi in range(len(f2))]


has_black_list = []
for wj in range(w):
    has_black = False
    for hi in range(len(f2)):
        if f2_char[hi][wj] == "
            has_black = True    
    
    if has_black:
        has_black_list.append(wj)
        
field_ans = [["" for wj in range(len(has_black_list))] for hi in range(len(f2))]
for j, wj in enumerate(has_black_list):
    for hi in range(len(f2)):
        field_ans[hi][j] = f2_char[hi][wj]
    

for hi in range(len(f2)):
    print("".join(field_ans[hi]))

Solution (Python):




def main():
    h, w = map(int, input().split())
    g = [list(input()) for i in range(h)]

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

    cnt = 0
    for i in r:
        g.pop(i-cnt)
        cnt += 1

    c = []
    for i in range(w):
        for j in range(h-len(r)):
            if g[j][i] == "
                break
        else:
            c.append(i)

    for i in range(h-len(r)):
        cnt = 0
        for j in c:
            g[i].pop(j-cnt)
            cnt += 1

    for i in range(h-len(r)):
        print("".join(g[i]))


if __name__ == '__main__':
    main()

Solution (Python):


H,W = map(int, input().split())
HW = []
for i in range(H):
    instr = input()
    if instr.find('
        HW.append(list(instr))
    else:
        H -= 1


HW2 = []
for x in zip(*HW):
    HW2.append(x)

HW3 = []
for i in range(W):
    instr = ''.join(HW2[i])
    if instr.find('
        HW3.append(HW2[i])


HW4 = []
for x in zip(*HW3):
    HW4.append(x)

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

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

a2_list = []
for a in a_list:
    if a.count(".") == W:
        continue
    else:
        a2_list.append(a)
a3_list = []
for j in range(W):
    row = "".join([r[j] for r in a2_list])
    if row.count(".") == len(a2_list):
        continue
    else:
        a3_list.append(row)

for i in range(len(a3_list[0])):
    row = [r[i] for r in a3_list]
    print("".join(row))

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

l1 = [x for x in l if x != '.'*W]

l2 = [''.join(x) for x in zip(*l1)]

l3 = [x for x in l2 if any([y if y != '.' else False for y in x])]

print("\n".join([''.join(x) for x in zip(*l3)]))

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

i = 0
while i < H:
    if '
        del table[i]
        H -= 1
    else:
        i = i + 1

table_t = [list(x) for x in zip(*table)]

i = 0
while i < W:
    if '
        del table_t[i]
        W -= 1
    else:
        i = i + 1

table = [list(x) for x in zip(*table_t)]

for i in range(H):
    print("".join(table[i]))

Solution (Python):


line = input().split()
h = int(line[0])
w = int(line[1])

a = []
hr = []
for hi in range(h):
    line = list(input())
    if len(set(line))==1 and line[0]==".":
        hr.append(hi)
    a.append(line)


wr = []
wi = 0
for line in zip(*a):
    if len(set(line))==1 and line[0]==".":
        wr.append(wi)
    wi += 1

for hi in range(h):
    if hi in hr:
        continue
    for wi in range(w):
        if wi not in wr:
            print(a[hi][wi], end="")
    print("")

Solution (Python):
import numpy as np

inputs = raw_input().replace("\n", "")
H, W = map(int, inputs.split(" "))

lines = np.asarray([list(raw_input().replace("\n", "")) for h in xrange(H)])

h_indexs, w_indexs = map(set, np.where(lines == "

outlines = lines[list(h_indexs), :][:, list(w_indexs)]
for outline in outlines:
    print "".join(outline)

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

a = []

for _ in range(H):
    a.append(input())


h_remove_index = []
for h_i in range(H):
    if not "
        h_remove_index.append(h_i)





v_remove_index = []
for v_i in range(W):
    is_ok = True
    for h_i in range(len(a)):
        if a[h_i][v_i] == "
            is_ok = False
            break
    
    if is_ok:
        v_remove_index.append(v_i)
    

for h_i in range(H):
    if h_i in h_remove_index:
        continue
    for v_i in range(W):
        if v_i in v_remove_index:
            continue

        print(a[h_i][v_i], end='')
    print("\n",end='')