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())
t=[]
for _ in[0]*H:
    x=input()
    if x!='.'*W:
        t+=[x]
num=len(t)
k=[]
for s in zip(*t):
    s=''.join(s)
    if s!='.'*num:
        k+=[s]
for x in zip(*k[::-1]):
    print(''.join(x[::-1]))

Solution (Python):
import numpy as np
h, w = [int(_) for _ in input().split()]

a = np.empty((h, w), dtype=np.str)
for i in range(0, h):
    a[i] = list(input())


height = h
i = 0
while True:
    if i == height:
        break
    if not '
        a = np.delete(a, i, axis=0)
        height -= 1
    else:
        i += 1

width = w
i = 0
while True:
    if i == width:
        break
    if not '
        a = np.delete(a, i, axis=1)
        width -= 1
    else:
        i += 1

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

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

M = list( input() for _ in range(H) )
A=[]
C=[]
r=0
c=W



for i in range(H):
	m = M[i]
	if "
		A.append(m)
		r+=1




for j in range(c):
	for i in range(r):
		a = A[i][j]
		if a=='
	else:
		C.append(j)



for r in A:

	for c in range(len(r)):
		if not (c in C):
			print(r[c], end='')
	print('')

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

matrix = []

for i in range(h):
  row = list(input())
  if '
    continue
  else:
    matrix.append(row)

removed_index = []

for i in range(len(matrix[0])):
  col = [row[i] for row in matrix]
  if '
    removed_index.append(i)

removed_index.reverse()

for n in removed_index:
  for row in matrix:
  	del row[n]

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

Solution (Python):
a,b=map(int, input().split(" "))
arr=[]
for i in range(a):
    line=list(input())
    
    arr.append(line)
    
    
    
    
    

out=[]
for i in arr:
    if "
        out.append(i)

count={}
for i in range(len(out)):
    for j in range(len(out[0])):
        if j not in count:
            count[j]=0
        if out[i][j]=="
            count[j]+=1




for line in out:
    result=""
    for num,i in enumerate(line):
        if count[num]!=0:
            result+=i

    if result != "":
        print(result)

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

a = [i for i in range(h)]
for i in range(h):
    if string[i] == "."*w:
        a.remove(i)

stringT = [[string[j][i] for j in range(h)] for i in range(w)]

b = [i for i in range(w)]

for i in range(w):
    if "".join(stringT[i]) == "."*h:
        b.remove(i)

st = [[string[i][j] for j in b] for i in a]
for i in range(len(st)):
    print("".join(st[i]))

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

list1=[]
for i in range(H):
    a=input()
    if a.count(".")==len(a):
        pass
    else:
        list2=[]
        for m in range(len(a)):
            
            list2.append(a[m])
        list1.append(list2)
        list2=[]

list3=[]
for j in range(W):
    count=0
    if list1[0][j]==".":
        for k in range(len(list1)):
            if list1[k][j]==".":
                count+=1
        if count==len(list1):
            list3.append(j)
            


list4=[]
for x in range(len(list1)):
    list5=[]
    for y in range(W):
        if y in list3:
            pass
        else:
            list5.append(list1[x][y])
    list4.append(list5)
    list5=[]


for c in range(len(list4)):
    print("".join(list4[c]))

Solution (Python):
inputs = input().strip().split()

H = int(inputs[0])
W = int(inputs[1])

a = []

for i in range(H):
    inputs = input()
    a.append(inputs)

for i in range(W):
    flag = True
    for j in range(H):
        if a[j][i] == "
            flag = False
    if flag:
        for j in range(H):
            a[j] = a[j][:i] + '*' + a[j][i+1:]

for i in range(H):
    if a[i].find("
        a[i] = ''

for i in range(H):
    if a[i] != '':
        print(a[i].replace('*', ''))

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

b = []
for y in range(len(a)):
    for x in range(len(a[y])):
        if a[y][x] != '.':
            b.append(a[y])
            break

c = ['' for _ in range(len(b))]
for x in range(len(b[0])):
    for y in range(len(b)):
        if b[y][x] != '.':
            for y in range(len(b)):
                c[y] += b[y][x]
            break

print('\n'.join(c))

Solution (Python):
import numpy as np

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

ans = []
for i in range(H):
  ans.append(input())
  
ind = []
k = len(ans)
for i, ss in enumerate(reversed(ans)):
  if ss == "." * W:
    ind.append(k-i-1)
  
index = []
for i in range(H):
  for j in range(W):
    if ans[i][j] == "
      index.append(j)

for i in range(H):
  if i in ind:
    continue
  aaa = ""
  for j in range(W):
    if j in index:
      aaa += ans[i][j]
      
  print(aaa)

Solution (Python):
H,W = [int(i) for i in input().split()]
A = [input() for _ in range(H)]
B = []
for i in range(H-1,-1,-1):
    if not "
        del A[i]
for i in range(W):
    flag = True
    for j in range(len(A)):
        if A[j][i] == "
            flag = False
    if flag:
        B.append(0)
    else:
        B.append(1)
for i in A:
    tmp = ""
    for j in range(len(i)):
        if B[j]:
            tmp+=i[j]
    print(tmp)

Solution (Python):
inp = list(map(int, input().split()))
H, W = inp[0], inp[1]

import numpy as np

arr = np.array([[0 if e == '.' else 1 for e in input().split()[0]] for _ in range(H)])

h = []
for i in range(H):
    if (arr[i] == [0] * W).all():
        h.append(i)
ind = np.ones(H, dtype=bool)
ind[h] = False
arr = arr[ind]

w = []
for i in range(len(arr[0])):
    if (arr[:, i] == [0] * len(arr[:,0])).all():
        w.append(i)
ind = np.ones(len(arr[0]), dtype=bool)
ind[w] = False
arr = arr[:, ind]

for i in range(len(arr)):
    txt = ''
    for j in range(len(arr[0])):
        if arr[i][j] == 0:
            txt += '.'
        else:
            txt += '
    print(txt)

Solution (Python):
a, b = map(int, input().split())
v = ['' for i in range(a)]
for i in range(a):
    v[i] = input()
for i in range(a):
    k = a - i - 1
    x = 0
    for j in range(b):
        if v[k][j] == '
            x = 1
    if x == 0:
        v.pop(k)



for i in range(b):
    k = b - i - 1
    x = 0
    for j in range(len(v)):
        if v[j][k] == '
            x = 1
    if x == 0:
        for j in range(len(v)):
            v[j] = v[j][:k] + v[j][k+1:]
            
for i in v:
    print(i)

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

D = []
f = [0] * W
for i in range(H):
    d = input()
    if d.count('.') == W:
        continue
    D.append(d)
    for j in range(W):
        if d[j] == '.':
            f[j] += 1

re = [''] * len(D)
for i in range(len(D)):
    str = D[i]
    for j in range(len(str)):
        if f[j] != len(D):
            re[i] += str[j]

for str in re:
    print(str)

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

grid = []
dot_h = []
sharp_h = []
dot_w = []
sharp_w = []

for h in range(H):
    line = input()
    line = line[:W]
    grid.append(line)
    if line.count('.') == W:
        dot_h.append(h)
    
    
for w in range(W):
    dot_c = 0
    sharp_c = 0
    for h in range(H):
        if grid[h][w] == '.':
            dot_c += 1
        
        
    if dot_c == H:
        dot_w.append(w)
    if sharp_c == H:
        sharp_w.append(w)
    
for h in range(H):
    if h in dot_h or h in sharp_h:
        continue
    for w in range(W):
        if w in dot_w or w in sharp_w:
            continue
        
        sys.stdout.write(grid[h][w])
    print('')

Solution (Python):
def main():
    H, W = map(int, input().split())
    a = []
    for _ in range(H):
        a.append(input())
    h = []
    w = []
    for i in range(H):
        if a[i] == "."*W:
            h.append(i)
    for i in range(W):
        b = ""
        for j in range(H):
            b += a[j][i]
        if b == "."*H:
            w.append(i)
    
    for i in range(H):
        out = ""
        for j in range(W):
            if (i in h) or (j in w):
                out += ""
            else:
                out += a[i][j]
        if out != "":
            print(out)

if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np

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

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

    arr = np.array(arr)
    yoko = []
    tate = []

    for i in range(h):
        if np.any(arr[i]=='
            yoko.append(i)

    for i in range(w):
        if np.any(arr.transpose()[i]=="
            tate.append(i)

    arr = np.delete(arr, yoko, 0)
    arr = np.delete(arr, tate, 1)

    for i in arr:
        print("".join(i))



if __name__ == "__main__":
        main()

Solution (Python):
import numpy as np

line = input().split()
H = int(line[0])
W = int(line[1])

array = np.ndarray((H, W), np.uint8)

for i in range(H):
    line = input()
    for j in range(W):
        if line[j] == '.':
            array[i, j] = 0
        elif line[j] == '
            array[i, j] = 1

W_condition = np.sum(array, axis=0)!=0
H_condition = np.sum(array, axis=1)!=0

array = array[H_condition, :]
array = array[:, W_condition]

h, w = array.shape

for i in range(h):
    line = ''
    for j in range(w):
        if array[i, j] == 0:
            line += '.'
        elif array[i, j] == 1:
            line += '
    print(line)

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

for _ in range(H):
  s = input()
  if '
    arr.append(s)

j = 0
while len(arr[0]) > j:
  if '
    for i in range(len(arr)):
      arr[i] = arr[i][:j] + arr[i][(j+1):]
  else:
    j += 1

for s in arr:
  print(s)

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

while ["."]*W in a:
    a.remove(["."]*W)
    H -= 1

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

while ["."]*H in a_t:
    a_t.remove(["."]*H)

a = [list(x) for x in zip(*a_t)]
a_ = [''.join(x) for x in a]
[print(x) for x in a_]

Solution (Python):
def run(h, w, a):
    ret1 = []
    for i in range(h):
        if a[i] != '.'*w:
            ret1.append(a[i])
    wi = []
    for i in range(len(ret1[0])):
        for j in range(len(ret1)):
            if ret1[j][i] == '
                wi.append(i)
                break
    ret = []
    for i in range(len(ret1)):
        s = ''
        for j in wi:
            s += ret1[i][j]
        ret.append(s)
    return ret


def read_line():
    h, w = map(int, input().split())
    a = []
    for i in range(h):
        a.append(input())
    return (h, w, a)


def main():
    h, w, a = read_line()
    ret = run(h, w, a)
    for i in range(len(ret)):
        print(ret[i])


if __name__ == '__main__':
    main()

Solution (Python):
H,W = map(int,input().split())
grid = []
for i in range(H):
    row = list(input())
    grid.append(row)
while True:
    r_change = False
    for q in range(len(grid)):
        if "
            del grid[q]
            r_change = True
            break
    if not r_change:
        break
while True:
    c_change = False
    for k in range(len(grid[0])):
        if "
            grid = [[row[p] for p in range(len(row)) if p != k] for row in grid]
            c_change = True
            break
    if not c_change:
        break
for row in grid:
    print("".join(row))

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

BW=[]
for i in range(H):
  nextline=list(input())
  for j in range(W):
    if nextline[j]=='
      BW.append(nextline)
      break;

columnWlist=[1]*(W)
for i in range(len(BW)):
  for j in range(W):
    if columnWlist[j]==1 and BW[i][j]=='
      columnWlist[j]=0

for i in range(len(BW)):
  for j in range(W-1,-1,-1):
    if columnWlist[j]==1:
      BW[i].pop(j)
      
for i in range(len(BW)):
  for j in range(len(BW[0])):
    print(BW[i][j],end='')
  print()

Solution (Python):
a,b=map(int,input().split())
s=[]
dels=[]
for i in range(a):
    s.append(input())
for i in range(len(s)):
    f=1
    for j in range(b):
        if s[i][j]!='.':
            f=0
            break
    if f:
        dels.append(i)
k=0
for i in dels:
    del s[i-k]
    k=k+1
dels=[]
for i in range(b):
    f=1
    for j in range(len(s)):
        if s[j][i]!='.':
            f=0
            break
    if f:
        dels.append(i)



for i in dels:
    for j in range(len(s)):
        s[j]=s[j][:i]+' '+s[j][i+1:]

for i in s:
    for j in i:
        if j!=' ':
            print(j,end='')
    print()

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

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

newdots = []
for dot in dots:
    if dot == '.' * W:
        pass
    else:
        newdots.append(dot)


newdots2 = list(zip(*newdots))
dots = []
for dot in newdots2:
    flag = True
    for d in dot:
        if d == '
            flag = False

    if flag is False:
        dots.append(dot)

newdots3 = list(zip(*dots))
for d in newdots3:
    print("".join(d))

Solution (Python):

"""
Created on Wed Jul 18 00:01:41 2018

@author: Yuya
"""

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

ans = []
c = 0

for i in range(n):
    tmp=list(input())
    f = 1
    for j in range(m):
        if tmp[j]=="
            f = -1
    if f<0:
        ans.append(tmp)
        c+=1


ans2 = [["0" for i in range(c)] for j in range(m)]

for i in range(m):
    for j in range(c):
        ans2[i][j] = ans[j][i]


d = m

for i in range(m-1, -1, -1):
    f = 1
    for j in range(c):
        if ans2[i][j]=="
            f = -1
    if f>0:
        del ans2[i]
        d-=1
        


ans3 = [["0" for i in range(d)] for j in range(c)]

for i in range(d):
    for j in range(c):
        ans3[j][i] = ans2[i][j]



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

Solution (Python):
import numpy as np

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

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

a2 = []
for i in range(w):
    b = [e[i] for e in a]
    if '
        a2.append(b)

a = np.array(a2).T

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

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





for i in range(h):
    
    row = table[h-1-i]
    row = list(set(row))
    if row == ["."]:
        table.pop(h-1-i)






l = []
for j in range(w):
    
    
    col = [r[w-1-j] for r in table]
    
    col = list(set(col))
    if col == ["."]:
        
        l.append(w-1-j)
        
        






out = []
for r in table:
    ll = list(r)
    for ind in l:
        ll.pop(ind)

    out.append("".join(ll))



for r in out:
    print(r)

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

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


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

    if not b:
        return [[]]

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

    if not idxes:
        return [[]]

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

    return ans


if __name__ == '__main__':
    main()

Solution (Python):
n,m = map(int, raw_input().split())
mat = []
for i in xrange(n):
    mat.append(list(raw_input()))

l = [[0 for i in xrange(m)] for j in xrange(n)]

for i in xrange(n):
    flag = 0
    for j in xrange(1,m):
        if mat[i][j] != mat[i][0]:
            flag = 1
    if flag or mat[i][0] != '.':
        for j in xrange(m):
            l[i][j] = 1


for i in xrange(m):
    flag = 0
    for j in xrange(1,n):
        if mat[j][i] != mat[0][i]:
            flag = 1

    if not flag and mat[0][i] == '.':
        for j in xrange(n):
            l[j][i] = 0



for i in xrange(n):
    s = ''
    for j in xrange(m):
        if l[i][j]:
            s += mat[i][j]
    if s != '':
        print s

Solution (Python):
def abc107_b():
    import numpy as np

    h, w = map(int, input().split())
    a = []
    for i in range(h):
        tmp = list(input())
        if not tmp == ["."] * w:
            a = np.append(a, tmp)
    a = a.reshape((-1, w))

    return a[:, np.any(a != np.array(["."] * w), axis=0)]

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

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

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

newmat = []

for i in range(H):
    if matrix[i] == '.'*W:
        continue
    else:
        newmat.append(matrix[i])
        
printW = []
for x in range(W):
    for lin in newmat:
        if lin[x] == '
            printW.append(x)
            break
        
for lin in newmat:
    str = ''
    for w in printW:
        str += lin[w]
    print(str)

Solution (Python):
import numpy as np
import math


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

A = np.zeros((H, W), dtype=int)

for h in range(H):
    ah = input()
    for w in range(W):
        if ah[w] == '.':
            A[h][w] = 0
        else:
            A[h][w] = 1


remH = []
remW = []
            
for h in range(H):
    if all(A[h] == 0):
        remH.append(h)
for w in range(W):
    if all(A[:,w] == 0):
        remW.append(w)


        
ret = []

for h in range(H):
    if h in remH:
        continue
    hlist = []
    for w in range(W):
        if w in remW:
            continue
        
        
        
        hlist.append(A[h][w])
    ret.append(hlist)



retH = H - len(remH)
retW = W - len(remW)


for x in range(retH):
    for y in range(retW):
        if ret[x][y] == 0:
            print('.', end='')
        else:
            print('
    print()

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

aa = []
for i in range(h):
    if a[i] != ["."]*w:
         aa.append(a[i])
        

import numpy as np

aaa = np.array(aa)

aaaa=[]
for i in range(aaa.T.shape[0]):
    if "".join(aaa.T[i]) != "."*aaa.T.shape[1]:
         aaaa.append(aaa.T[i])
            
tm = np.array(aaaa).T

for i in range(tm.shape[0]):
    print("".join(tm[i]))

Solution (Python):
H, W = map(int, input().split())
A = []
for i in range(H):
    l = list(input())
    if not all(a=='.' for a in l):
        A.append(l)
d = []
for i in range(W):
    if all(aa[i]=='.' for aa in A):
        d.append(i)

B = []
for aa in A:
    l = ''
    for i, a in enumerate(aa):
        if i not in d:
            l += a
    B.append(l)
        
for bb in B:
    print(bb)

Solution (Python):
H,W = map(int, input().split())
A = [[0 for _ in range(W+1)] for _ in range(H+1)]
for h in range(H):
  l = input()
  for w in range(W):
    A[h][w] = 0 if l[w] == '.' else 1
for h in range(H):
  n = 0
  for w in range(W):
    n += A[h][w]
  A[h][W] = n
for w in range(W):
  n = 0
  for h in range(H):
    n += A[h][w]
  A[H][w] = n
for h in range(H):
  if A[h][W] == 0: continue
  ans = []
  for w in range(W):
    if 0 < A[H][w]:
      ans.append('.' if A[h][w] == 0 else '
  print(''.join(map(str,ans)))

Solution (Python):
a = input().split()
h = int(a[0])
w = int(a[1])

m = []
for i in range(h):
	sb = input()
	if not  sb == '.'*w:
		m.append(sb)
			
if not m == []:
	output = [[] for i in range(len(m))]
	for i in range(len(m[0])):
		notok = True
		for j in range(len(m)):
			notok = notok and (m[j][i] == '.')
			if notok == False:
				break
		if notok == False:
			for j in range(len(m)):
				output[j].append(m[j][i])
				
for i in range(len(output)):
	print(''.join(output[i]))

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

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

removelist = []
for i in range(W):
	for j in range(H):
		if li[j][i] == "
			break
	else:
		removelist.append(i)

for i in reversed(removelist):
	for j in range(H):
		li[j] = li[j][:i] + li[j][i+1:]

for i in range(H):
	print(li[i])

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

a = []

for i in range(h):
    str_list = input()
    a_list = [0 if j == "." else 1 for j in str_list]
    a.append(a_list)

i = 0
while i < h:
    if i > len(a)-1:
        break
    if sum(a[i]) == 0:
        a.pop(i)
        i-=1
    i+=1


i = 0
while i < w:
    if i > len(a[0])-1:
        break
    if sum([a[j][i] for j in range(len(a))]) == 0:
        for j in range(len(a)):
            a[j].pop(i)
        i-=1
    i+=1


for i in range(len(a)):
    outlist = ["." if a[i][j] == 0 else "
    str_list = ""
    for j in outlist:
        str_list+=j
    print(str_list)

Solution (Python):
def linecheck(a,i):
    for j in range(W):
        if a[i][j] != ".":
            return False
    return True
def colcheck(a,j,H):
    for i in range(H):
        if a[i][j] != ".":
            return False
    return True
H,W = map(int,input().split())
a = []
for i in range(H):
    a.append(list(input()))
i = 0
while i<H:
    if linecheck(a,i):
        del a[i]
        i = 0
        H -= 1
    else:
        i += 1
j = 0
while j<W:
    if colcheck(a,j,H):
        for i in range(H):
            del a[i][j]
        j = 0
        W -= 1
    else:
        j += 1
for i in range(H):
    print("".join(a[i]))

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

bad_row = set()
bad_column = set()
for i in range(H):
    if all([x == '.' for x in matrix[i]]):
        bad_row.add(i)

for j in range(M):
    tmp = [matrix[i][j] for i in range(H)]
    if all([x == '.' for x in tmp]):
        bad_column.add(j)

for i in range(H):
    for j in range(M):
        if i not in bad_row:
            if j not in bad_column:
                print(matrix[i][j], end='')
    if i not in bad_row:
        print('')

Solution (Python):

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

a2 = []
for item in a:
    if item == "." * W: continue
    a2.append(item)

white = []
for j in range(W):
    for item in a2:
        if item[j] == "
        else: continue
    else:
        white.append(j)

a3 = []
for item in a2:
    line = ""
    for j in range(W):
        if j in white: continue
        line += item[j]
    a3.append(line)

for item in a3: print(item)

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

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

x2  = []
for i in x:
    if '
        x2.append(i)

de = []

for i in range(w):
    flag = 0
    for line in x2:
        if line[i] == '
            flag = 1
            break
    if flag == 0:
        de.append(i)

for line in x2:
    st = ""
    for i in range(w):
        if i in de:
            pass
        else:
            st += line[i]
    print(st)

Solution (Python):
h, w = map(int, input().split())
A = []
for i in range(h):
    s = input()
    if s != "." * w:
        A.append(s)

h = len(A)
white_col_index = []
for j in range(w):
    s = "".join([A[i][j] for i in range(h)])
    if s == "." * h:
        white_col_index.append(j)

output_col_index = sorted(list(set(range(w)) - set(white_col_index)))
for i in range(h):
    print("".join(A[i][j] for j in output_col_index))

Solution (Python):
import numpy
H, W = [int(i) for i in input().split()]
A = numpy.array([list(input().strip()) for _ in range(H)])

row_space = []
col_space = []

for k, row in enumerate(A):
    if '
        row_space.append(k)

A_rot = numpy.rot90(A, k=-1)
for k, row in enumerate(A_rot):
    if '
        col_space.append(k)

A = numpy.delete(A, row_space, axis=0)
A = numpy.delete(A, col_space, axis=1)
ans = '\n'.join([''.join(row) for row in A])
print(ans)

Solution (Python):
H, W = map(int,input().split())
A = [input() for k in range(H)]
B = []
for k in range(len(A)):
    if A[k] != "."*W:
        B.append(A[k])

C = []
for k in range(len(B[0])):
    T = ""
    for l in range(len(B)):
        T += B[l][k]
    C.append(T)

D = []
for k in range(len(C)):
    if C[k] != "."*len(C[0]):
        D.append(C[k])

for k in range(len(D[0])):
    T = ""
    for l in range(len(D)):
        T += D[l][k]
    print(T)

Solution (Python):
input_s = str(input())
[n, k] = list(map(int, input_s.split(' ')))
m = []
for i in range(0, n):
    tmp = str(input())
    if tmp.find('
        m.append(tmp)
ta = []
for i in range(0, k):
    tmp = ''
    for j in m:
        tmp += j[i]

    ta.append(tmp)
tb = []
for i in ta:
    if i.find('
        tb.append(i)

result = []
for i in range(0, len(tb[0])):
    tmp = ''
    for j in tb:
        tmp += j[i]
    result.append(tmp)

for i in result:
    print(i)

Solution (Python):
nums = [int(num) for num in input().split()]
h = nums[0]
w = nums[1]
a = []
for i in range(h):
    a.append(input())
b = []
for i in range(h):
    hoge = True
    for j in range(w):
        if a[i][j] =="
            hoge = False

    if not hoge:
        b.append(a[i])


c = []

for i in range(w):
    hoge = True
    for j in range(len(b)):
        if b[j][i] == "
            hoge = False
    if not hoge:
        c.append(i)

ans = []
for i in range(len(b)):
    hoge =""
    for j in range(w):
        if j in c:
            hoge = hoge+b[i][j]
    ans.append(hoge)
        

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

Solution (Python):


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

    for i in range(h):
        if len(set(arry[i])) == 1 and arry[i][0] == '.':
            continue
        else:
            arry_new.append(arry[i])

    for j in range(len(arry_new[0])):
        flag = 1
        for k in range(len(arry_new)):
            if arry_new[k][j] == '.':
                flag *= 1
            else:
                flag *= 0
        if flag == 1:
            for l in range(len(arry_new)):
                arry_new[l][j] = ''
    for ans in arry_new:
        for i in ans:
            print(i, end='')
        print('')

if __name__ == '__main__':
    main()

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

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

yoko = []
for i in range(H):
    shiro = True
    for j in range(W):
        if a[i][j] != ".":
            shiro = False
    if shiro:
        yoko.append(i)

tate = []
for i in range(W):
    shiro = True
    for j in range(H):
        if a[j][i] != ".":
            shiro = False
    if shiro:
        tate.append(i)

for i in range(H):
    tmp = ""
    for j in range(W):
        if (j not in tate) and (i not in yoko):
            tmp = tmp + a[i][j]
    if tmp != "":
        print(tmp)

Solution (Python):
n,m=map(int,input().split())
arr=[]
for i in range(n):
    s1=str(input())
    arr.append(s1)
row1=[]
col1=[]
for i in range(n):
    if(arr[i].count('.')<m):
        row1.append(i)
for j in range(m):
    for i in range(n):
        if(arr[i][j]!='.'):
            col1.append(j)
            break
for i in row1:
    s1=""
    for j in col1:
        s1+=arr[i][j]
    print(s1)

Solution (Python):

import numpy as np

def solve():
    H, W = map(int, input().split())
    M = np.array([list(input())])
    for h in range(H-1):
        M = np.vstack((M,np.array([list(input())])))

    h = np.where(~(M == '.').all(axis=1))[0]
    v = np.where(~(M == '.').all(axis=0))[0]
    M = M[h,:][:,v]

    return '\n'.join([''.join([b for b in a]) for a in M])

if __name__ == '__main__':
    print(solve())

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

b = []
for i in range(h):
    flag = 1
    for j in range(w):
        if a[i][j] == "
            flag = 0
    if not flag:
        b.append(a[i])

s = set()
for j in range(w):
    flag = 1
    for i in range(len(b)):
        if b[i][j] == "
            flag = 0
    if flag:
        s.add(j)

for i in b:
    c = ""
    for j in range(len(i)):
        if not j in s:
            c += i[j]
    print(c)

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

row = []
for i in range(H):
    line = input()
    if line.count(".") == W:
        continue
    row.append(line)

row_count = len(row)
ans = [[] for i in range(row_count)]
for i in range(W):
    tmp = []
    for j in range(row_count):
        tmp.append(row[j][i])
    if tmp.count(".") == row_count:
        continue
    else:
        for index, c in enumerate(tmp):
            ans[index].append(c)
for i in ans:
    print("".join(i))

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

for i in range(h-1,-1,-1):
    if not '
        del a[i]
h = len(a)
for j in range(w-1, -1, -1):
    res = True
    for i in range(h):
        if a[i][j] == '
            res = False
    if res:
        for i in range(h):
            del a[i][j]

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

Solution (Python):
import sys

ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: [int(x) for x in ns().split()]
nall = lambda: [int(x) for x in sys.stdin.readlines()]
sall = lambda: sys.stdin.readlines()

def main():
    h, w = na()
    a = sall()

    hs = []
    for i in range(h):
        if not [v for v in a[i] if v == '
            hs.append(i)

    ws = []
    for i in range(w):
        if not [a[j][i] for j in range(h) if a[j][i] == '
            ws.append(i)

    for i in range(h):
        p = False
        for j in range(w):
            if i in hs or j in ws:
                continue
            print(a[i][j], end='')
            p = True

        if p:
            print('')
            
main()

Solution (Python):
h,w = map(int,input().split())
ans = []
n = h
for i in range(h):
  s = input()
  if("
    ans.append(s)
  else:
    n -= 1
i = 0
j = w-1
while True:
  if(i > j):
    break
  flg = True
  for k in range(n):
    if(ans[k][i] == "
      flg = False
      break
  if(flg):
    for k in range(n):
      ans[k] = ans[k][:i] + ans[k][i+1:]
    j -= 1
  else:
    i += 1
for i in ans:
  print(i)