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())
a = []
for _ in  range(h):
    k = input()
    if "
        a.append([i for i in k])
        
import numpy as np
for i in np.array([i for i in np.array(a).T if "
    print("".join(i))

Solution (Python):

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

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


row_compare=['.' for i in range(w)]
save_rows=[]
for row in range(h):
    if not l[row]==row_compare:
        save_rows.append(row)

newl=[l[row] for row in save_rows]

h=len(newl)

save_col=[]
col_compare=["." for i in range(h)]
for col in range(w):
    temp=[]
    for row in range(h):
        temp.append(newl[row][col])
    if not temp==col_compare:
        save_col.append(col)

ansl=[]
for row in range(h):
    temp=[]
    for col in range(w):
        if col in save_col:
            temp.append(newl[row][col])
    ansl.append(temp)

for row in ansl:
    print(*row,sep="")

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

lis = []
for _ in range(h):
    tmp = input()
    lis.append(list(tmp))
    
flag = 0
delg = []
for i in range(h):
    for j in range(w):
        if lis[i][j] == "
            flag = 1
            break
        else:
            flag = 0
    
    if flag == 0:
        delg.append(i)
        
nlis = []

if delg != False:    
    for k in range(h):
        if k not in delg:
            nlis.append(lis[k])
            
h = h - len(delg)

flg = 0
delr = []

for k in range(w):
    for i in range(h):
        if nlis[i][k] == "
            flg = 1
            break
        else:
            flg = 0
    
    if flg == 0:
        delr.append(k)
        
delr = list(reversed(delr))


if delr != False:
    for i in range(h):
        for j in delr:
            nlis[i].pop(j)

for l in nlis:
    print("".join(l))

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

dh = []
for l in A:
    if l[0] == '.' and len(set(l)) == 1:
        continue
    dh.append(l)

wj = []
for j in range(w):
    for i in range(len(dh)):
        if dh[i][j] == '
            wj.append(j)
            break

ans = ['' for _ in range(len(dh))]
for i in range(len(ans)):
    for j in wj:
        ans[i] += dh[i][j]
print('\n'.join(ans))

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

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

l=[]
for i in range(len(A[0])):
    x=0
    for j in range(len(A)):
        if A[j][i]==".":
            x+=1
    if x==len(A):
        l.append(i)

for i in range(len(A)):
    ans=""
    for j in range(len(A[0])):
        if j in l:
            continue
        else:
            ans+=A[i][j]
    print(ans)

Solution (Python):
H,W=map(int,input().split())
a=[[""]*W for i in range(H)]
for i in range(H):
  a[i]=list(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]==True:
    for j in range(W):
      if col[j]==True:
        print(a[i][j],end="")
    print("")

Solution (Python):
import sys
import numpy as np

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007



def kk(al):
	for i in range(len(al)-1, -1, -1):
		if list(al[i]) == ['.']*len(al[i]):
			al = np.delete(al, i, 0)
	return al

def main():
	
	h, w = tin()
	
	al=[]
	for _ in range(h):
		s=list(input())
		al.append(s)
	al = np.array(al)
	al = kk(al)
	al = kk(al.T)
	al=al.T
	for v in al:
		print(''.join(v))
		
	
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):
def mi():
    return map(int, input().split())

def ii():
    return int(input())

def cut(a):
    w = len(a[0])
    l = []
    for row in a:
        if row != ['.']*w:
            l.append(row)
    return l

def main():
    H, W = mi()
    a = [list(input()) for _ in range(H)]
    a = cut(a)
    a = cut([list(i) for i in zip(*a)])
    [print(''.join(list(i))) for i in zip(*a)]

if __name__ == '__main__':
    main()

Solution (Python):
h,w = map(int,input().split())
array = []
for _ in range(h):
    temp = input()
    if temp.count(".")==w:
        h-=1
        continue
    array.append(temp)

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

for j in range(w):
    flag=0
    for i in range(h):
        if array[i][j]=="
            flag=1
            break
    if flag==0:
        skip.remove(j)

for i in range(h):
    for j in skip:
        print(array[i][j], end="")
    print()

Solution (Python):
h,w=map(int,input().split())
m=[]
for _ in range(h):
    l=input()
    if '
        m.append(l)
m=list(zip(*m))
n=[]
for i in m:
    if '
        n.append(i)
n=list(zip(*n))
for i in n:
    for j in i:
        print(j,end='')
    print('')

Solution (Python):
def resolve():
    H, W = [int(i) for i in input().split()]
    A = [input() for _ in range(H)]
    skipC = [False for _ in range(W)]
    skipR = [False for _ in range(H)]
    for i in range(H):
        if A[i] == "".join(["." for _ in range(W)]):
            skipR[i] = True
    for i in range(W):
        for j in range(H):
            if A[j][i] != ".":
                break
        else:
            skipC[i] = True

    for i in range(H):
        if skipR[i]:
            continue
        for j in range(W):
            if skipC[j]:
                continue
            print(A[i][j], end="")
        print("")


resolve()

Solution (Python):
H, W = map(int, input().split())
a = [input() for _ in range(H)]
temp = []
for i in range(H):
    if a[i] == ('.' * W):
        pass
    else:
        temp.append(a[i])
a = temp
temp = []
for i in range(W):
    flg = True
    for j in range(len(a)):
        if not a[j][i] == '.':
            flg = False
        if not flg:
            break
    else:
        temp.append(i)

for i in range(len(a)):
    for j in range(W):
        if j in temp:
            pass
        else:
            print(a[i][j], end='')
    print()

Solution (Python):
h,w = map(int,input().split())
a = [0]*h
for i in range(h):
    a[i] = list(input())
b = []
for i in range(h):
    if a[i] == ["."]*w:
        pass
    else:
        b.append(a[i])
c = [[0 for j in range(w)] for i in range(h)]
for i in range(w):
    sw = 1
    for j in range(len(b)):
        if  b[j][i] == "
            sw = 0
            break
    if sw == 0:
        for j in range(len(b)):
            c[j][i] = b[j][i]
for i in range(len(c)):
    for j in range(len(c[0])):
        if c[i][j] != 0:
            print(c[i][j],end="")
    print("")

Solution (Python):
import numpy as np











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

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


def calculate(h, w, arr):
    arr = np.array(arr)
    arr = np.where(arr == ".", 0, 1)
    s = np.sum(arr, axis=1)

    p = s > 0
    m = arr[p]


    t = np.sum(m, axis=0)

    o = t > 0

    res = m[:, o]

    res = np.where(res==1,"

    for re in res:
        print("".join(re))



calculate(H, W, ARR)

Solution (Python):
h, w = map(int, input().split())
a = [''] * h
for i in range(h):
	a[i] = 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()

Solution (Python):






import numpy as np





H,W = map(int, input().split())
a = []
for _ in range(H):
    row = input()
    a.append([1 if row[i] == "





a_array = np.array(a)
col_flag = True
row_flag = True

while col_flag:
    for col in range(len(a_array)):
        if sum(a_array[col]) == 0:
            a_array = np.delete(a_array, col, 0)

            break
    else:
        col_flag = False
while row_flag:
    for row in range(len(a_array[0])):
        if sum(a_array[:,row]) == 0:
            a_array = np.delete(a_array, row, 1)

            break
    else:
        row_flag = False
for i in range(len(a_array)):
    tmp = ["
    print("".join(tmp))

Solution (Python):
def main():
    H, W = map(int, input().split())
    A = [0]*H
    for i in range(H):
       A[i] = [a for a in input()]
    
    B = []
    for i in range(H):
        found = False
        for j in range(W):
            if A[i][j] == '
                found = True
                break
        if found:
            B.append(A[i])
    
    h = len(B)
    C = [[] for i in range(h)]
    for j in range(W):
        found = False
        for i in range(h):
            if B[i][j] == '
                found = True
                break
        if found:
            for i in range(h):
                C[i].append(B[i][j])
    for i in range(h):
        print(''.join(C[i]))


if __name__ == '__main__':
    main()

Solution (Python):















mod = int(1e9+7)

INF = 1<<50

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

def main():
    h,w = readInt()
    a = [input() for i in range(h)]
    H = []
    W = []
    for i in range(h):
        f = True
        for j in range(w):
            if a[i][j]=='
                f = False
                break
        if f:
            H.append(i)
    for i in range(w):
        f = True
        for j in range(h):
            if a[j][i]=='
                f = False
                break
        if f:
            W.append(i)
    ans = []
    for i in range(h):
        if i in H:
            continue
        x = []
        for j in range(w):
            if j in W:
                continue
            x.append(a[i][j])
        ans.append(x)
    for i in range(len(ans)):
        print(''.join(ans[i]))
    return

if __name__=='__main__':
    main()

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

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

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


for i in range(len(a[0])):
    for x in a:
        print(x[i], end='')
    print()

Solution (Python):
import numpy as np
h,w=map(int,input().split())
"""
入力はスペースなしだった
文字列としてリストの行にぶち込む必要あり
icon=list()
for i in range(h):
    icon.append(list(input().split()))

"""
icon=[''] * h
for i in range(h):
    icon[i]=input()


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

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

for  i in range(h):
    if row[i]==True:
        for j in range(w):
            if col[j]==True:
                print(icon[i][j],end='')
        print()

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

cols = []
for j in range(w):
  valid = False
  for i in range(h):
    if temp[i][j]=='
      valid = True
  if not valid:
    cols.append(j)
for i in range(h):
  for j in range(w):
    if j not in cols:
    	print(temp[i][j],end='')
  print()

Solution (Python):
h,w=map(int,input().split())
a=[input() for i in range(h)]
yoko=[]
tate=[]
for i in range(h):
  for j in range(w):
    if a[i][j]=="
      tate.append(i)
      break
for i in range(w):
  for j in range(h):
    if a[j][i]=="
      yoko.append(i)
      break
for i in tate:
  l=[a[i][j] for j in yoko]
  l="".join(l)
  print(l)

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

a = np.array(a).reshape(h, w)
a = [i for i in a if "

a = np.array(a).T
a = [i for i in a if "

a = np.array(a).T
for i in a:
    print("".join(i))

Solution (Python):
h, w = map(int, input().split())
a = [list(input()) for i in range(h)]
for i in range(2):
    a = [j for j in a if "
    a = list(map(list, (zip(*a))))
for i in a:
    print("".join(i))

Solution (Python):
h,w = map(int,input().split())
k = []
h_remove = []
w_remove = []
for i in range(h):
    ls = input()
    if ls.count(".") == w:
        h_remove.append(i)
    k.append(ls)
for i in range(w):
    now = ""
    for j in range(h):
        now += k[j][i]
    if now.count(".") == h:
        w_remove.append(i)
h_remove = set(h_remove)
w_remove = set(w_remove)
for i in range(h):
    ans = ""
    if i in  h_remove:
        continue
    else:
        for j in range(w):
            if j in w_remove:
                continue
            else:
                ans += k[i][j]
        print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    H, W = map(int, input().split())
    A = list(list(input()) for _ in range(H))

    res = []
    remove = 0
    for h in range(H):
        for w in range(W):
            if A[h][w] == "
                res.append(A[h])
                break
        else:
            remove += 1
    H -= remove

    res2 = [[] for _ in range(H)]
    for w in range(W):
        for h in range(H):
            if res[h][w] == "
                for i in range(H):
                    res2[i].append(res[i][w])
                break

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


if __name__ == '__main__':
    resolve()

Solution (Python):

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

row = [False]*H
col = [False]*W
for i in range(H):
    for j in range(W):
        if glid[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(glid[i][j],end="")

        print()

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

for i in range(2):
    grid = [col for col in grid if '
    grid = list(map(list, (zip(*grid))))

for g in grid:
    print(''.join(g))

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

s = []
for i in range(h):
    tmp = list(input())
    if "
        s.append(tmp)

c = [0]*w
for i in s:
    for j in range(w):
        if i[j] == "
            c[j] = 1

for i in s:
    for j in range(w):
        ans = i[j] if c[j] == 1 else ""
        print(ans, end="")
    print("")

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

non_h = []
for i in range(h):
  set_l = list(set(l[i]))
  if len(set_l) == 1 and set_l[0] == '.':
    non_h.append(i)
for i in range(len(non_h)):
  l.pop(non_h[i] - i)

non_w = []
for j in range(w):
  a = []
  for i in range(len(l)):
    a.append(l[i][j])
  b = list(set(a))
  if len(b) == 1 and b[0] == '.':
    non_w.append(j)

new_l = []
for i in range(len(l)):
  new = []
  for j in range(len(l[i])):
    if not j in non_w:
      new.append(l[i][j])
  new_l.append(new)

for e in new_l:
  for i in range(len(e)):
    print(e[i], end='')
  print()

Solution (Python):
h, w = map(int, input().split())
A = [[] for _ in range(h)]
for i in range(h):
    A[i] = list(input())
flag = True
while flag:
    flag = False
    for i, a in enumerate(A):
        if not '
            flag = True
            A.pop(i)
            break
    for j in range(len(A[0])):
        a = []
        for i in range(len(A)):
            a.append(A[i][j])
        if not '
            flag = True
            for i, a in enumerate(A):
                A[i].pop(j)
            break
for a in A:
    temp = ''.join(a)
    print(temp)

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

a = [list(input()) for i in range(H)]
cnt = 0
i = 0
while i < len(a):
    for j in range(W):
        if a[i][j] not in '
            cnt += 1
    if cnt == W:
        a.remove(a[i])
        i -= 1
        H -= 1
    cnt = 0
    i += 1
i = 0
cnt = 1
while i < W:
    if a[0][i] == '.':
        for j in range(1,H):
            if a[j][i] == '.':
                cnt += 1
        if cnt == H:
            for j in range(H):
                a[j].pop(i)
            W -= 1
            i -= 1
    cnt = 1
    i += 1
[print(''.join(a[i])) for i in range(H)]

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

l = [0]*w
for i in range(h) :
    for j in range(w) :
        if A[i][j] == '.' :
            l[j]+= 1

for i in range(w) :
    if l[i] == h :
        for j in range(h) :
            A[j][i] = 0

for i in range(h) :
    aa = [i for i in A[i] if i != 0]
    ans = ''.join(aa)
    print(ans)

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

clm = [True] * H
for hi in range(H):
  ai = a[hi]
  for c in ai:
    if c == '
      clm[hi] = False
      break
      
row = [True] * W
for wi in range(W):
  for ci in range(H):
    if a[ci][wi] == '
      row[wi] = False
      break
      
for hi in range(H):
  if clm[hi] == True:
    continue
  ans = ''
  ai = a[hi]
  for wi in range(W):
    if row[wi] == True:
      continue
    ans += ai[wi]
  print(ans)

Solution (Python):
n, m=  map(int, input().split())
grid = []
for i in range(n):
    grid.append(list(input()))
i = 0
while i < n:
    replace = True
    for j in range(m):
        if grid[i][j] != '.':
            replace = False
            break
    if replace:
        grid.pop(i)
        n -= 1
    else:
        i+=1
i = 0
while i < m:
    replace = True
    for j in range(n):
        if grid[j][i] != '.':
            replace = False
            break
    if replace:
        for x in range(n):
            grid[x].pop(i)
        m-=1
    else:
        i+=1
for i in range(n):
    for j in range(m):
        print(grid[i][j], end='')
    print()

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

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

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

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

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

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

for i in range(H):
  is_in_black=False
  for j in range(W):
    if a[i][j]=='
      is_in_black=True
      break
  if is_in_black == False:
    for j in range(W):
      a[i][j]=0
  pass

for j in range(W):
  is_in_black=False
  for i in range(H):
    if a[i][j]=='
      is_in_black=True
      break
  if is_in_black == False:
    for i in range(H):
      a[i][j]=0
  pass


for i in range(H):
  ans = ''
  for j in range(W):
    if a[i][j]!=0:
      ans+=a[i][j]
  if len(ans)!=0:
    print(ans)

Solution (Python):
h,w = map(int,input().split())
ls = [list(input()) for _ in range(h)]
num = []
di = [0]*w
for i in range(h):
    if "
        num.append(i)
    for j in range(w):
        if ls[i][j] == "
            di[j] += 1
num = sorted(num,reverse=True)
for k in range(h-1,-1,-1):
    if k in num:
        ls.pop(k)
        continue
    for l in range(w-1,-1,-1):
        if di[l] == 0:
            ls[k] = ls[k][:l] + ls[k][l+1:]
for p in range(h-len(num)):
    print("".join(ls[p]))

Solution (Python):
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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

white_y = [0] * H
white_x = [1] * W

masu = []
for i in range(H):
    yoko = list(readline().decode("utf-8"))
    if not "
        white_y[i] = 1
    for j, x in enumerate(yoko):
        if x == "
            white_x[j] = 0
    masu.append(yoko)




for i in range(H):
    if white_y[i] == 1:
        continue
    s = ""
    for j in range(W):
        if white_x[j] == 1:
            continue
        s += masu[i][j]
    print(s)

Solution (Python):
h,w = map(int,input().split())
ls = [list(input()) for _ in range(h)]
num = []
di = [0]*w
for i in range(h):
    if "
        num.append(i)
    for j in range(w):
        if ls[i][j] == "
            di[j] += 1
num = sorted(num,reverse=True)
for k in range(h-1,-1,-1):
    if k in num:
        ls.pop(k)
        continue
    for l in range(w-1,-1,-1):
        if di[l] == 0:
            if l != 0 and l != w-1:
                ls[k] = ls[k][:l] + ls[k][l+1:]
            elif l == 0:
                ls[k] = ls[k][1:]
            else:
                ls[k] = ls[k][:w-1]
for p in range(h-len(num)):
    print("".join(ls[p]))

Solution (Python):


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

h = [0] * H
for i in range(H):
    for j in range(W):
        if A[i][j] == '
            h[i] = 1
            continue

w = [0] * W
for j in range(W):
    for i in range(H):
        if A[i][j] == '
            w[j] = 1
            continue

for i in range(H):
    ans = ''
    if h[i] == 0:
        continue
    for j in range(W):
        if w[j] == 0:
            continue
        else:
            ans += A[i][j]
    print(ans)

Solution (Python):


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

h = [0] * H
for i in range(H):
    for j in range(W):
        if A[i][j] == '
            h[i] += 1
            continue

w = [0] * W
for j in range(W):
    for i in range(H):
        if A[i][j] == '
            w[j] += 1
            continue

for i in range(H):
    ans = ''
    if h[i] == 0:
        continue
    for j in range(W):
        if w[j] == 0:
            continue
        else:
            ans += A[i][j]
    print(ans)

Solution (Python):


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

h = [0] * H
for i in range(H):
    for j in range(W):
        if A[i][j] == '
            h[i] += 1

w = [0] * W
for j in range(W):
    for i in range(H):
        if A[i][j] == '
            w[j] += 1

for i in range(H):
    ans = ''
    if h[i] == 0:
        continue
    for j in range(W):
        if w[j] == 0:
            continue
        else:
            ans += A[i][j]
    print(ans)

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

ans=[]
for i in range(h):
  if s[i]!='.'*w:
    ans.append(s[i])

n=len(ans)
a=['' for i in range(n)]

for i in range(w):
  sm=''
  cnt=0
  for j in range(n):
    sm+=ans[j][i]
    if ans[j][i]!='.':
      cnt+=1
  if cnt!=0:
    for k in range(n):
      a[k]+=ans[k][i]
m=len(a)
for i in range(m):
  print(a[i])

Solution (Python):
h,w = map(int,input().split())
a = [input() for _ in range(h)]
while "."*w in a:
	a.remove("."*w)
lena = len(a)
b = ["".join([a[i][j] for i in range(lena)]) for j in range(w)]
while "."*lena in b:
	b.remove("."*lena)
c = [[b[i][j] for i in range(len(b))] for j in range(len(a))]
for i in c:
	print("".join(i))

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()


def main():
    H, W = map(int, input().split())
    A = [list(input()) for _ in range(H)]
    omit = set([])
    for j in range(W):
        white = True
        for i in range(H):
            if A[i][j] == '
                white = False
                break
        if white: omit.add(j)
    for i in range(H):
        white = True
        for j in range(W):
            if A[i][j] == "
                white = False
                break
        if white: continue
        ans = ""
        for j in range(W):
            if j not in omit:
                ans += A[i][j]
        print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np

H, W = map(int, input().split())
a = np.zeros(shape=(H, W), dtype=bool)
for i in range(H):
  a[i] = [s == "." for s in input()]

y = [True] * H
for i in range(H):
  if all(a[i,:]):
    y[i] = False

x = [True] * W
for i in range(W):
  if all(a[:,i]):
    x[i] = False

ans = []
for i in range(H):
  if not y[i]:
    continue
  s = ""
  for j in range(W):
    if not x[j]:
      continue
    s = "".join([s, "." if a[i,j] else "
  ans.append(s)

print(*ans, sep="\n")

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

a = [0]*h
b = []
for i in range(0,h):
  a[i] = input()
  
i = 0
tmp = 0
for i in range(0,h):
  if a[i].count(".") == w:
    tmp += 1
  else:
    b.append(a[i])
    


b = list(zip(*b))

c = []
h = h - tmp

tmp = []

for i in range(0,w):
  if b[i].count(".") == h:
    continue
  else:
    c.append(b[i])
    


c = list(zip(*c))

for i in c:
  i = ''.join(i)
  print(i)

Solution (Python):
H,W=map(int,input().split())
M=[list(input()) for i in range(H)]
for i in range(H):
    if '
        s=[]
        for x in range(W):
            t=[M[y][x] for y in range(H)]
            if '
        print(''.join(s))

Solution (Python):
import numpy as np

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

for i in reversed(range(arr.shape[0])):
    if not '
        arr = np.delete(arr, i, 0)
        
for i in reversed(range(arr.shape[1])):
    if not '
        arr = np.delete(arr, i, 1)

a = arr.tolist()

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

Solution (Python):
height, width = map(int, input().split())
lis = [[0 for i in range(width)] for i in range(height)]
for i in range(height):
    lis[i] = input()

blank_rows = []
for row in range(height):
    if not "
        blank_rows.append(row)

blank_cols = []
for col in range(width):
    flag = 1
    for row in range(height):
        if "
            flag = 0
            break
    if flag:
        blank_cols.append(col)

for row in range(height):
    out = ""
    if not row in blank_rows:
        for col in range(width):
            if not col in blank_cols:
                out += lis[row][col]
    if not out == "":
	    print(out)

Solution (Python):

import math


def inp():
    return(int(input()))



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



def instr():
    s = input()
    return(list(s[:len(s)]))



def invr():
    return(map(int, input().split()))


r, c = invr()

a = []
for _ in range(r):
    a.append(instr())

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

for i in range(r):
    f = 0
    for j in range(c):
        if a[i][j] != "-1":
            f = 1
            print(a[i][j], end="")
    if f:
        print()

Solution (Python):
H, W = map(int, input().split())
grid = []
for i in range(H):
    row = list(input())
    grid.append(row)
row_flags = [1] * H
col_flags = [1] * W

for i in range(H):
    t = grid[i][0]
    if t != ".":
        continue
    for j in range(1, W):
        if grid[i][j] != t:
            break
    else:
        row_flags[i] = 0
for j in range(W):
    t = grid[0][j]
    if t != ".":
        continue
    for i in range(1, H):
        if grid[i][j] != t:
            break
    else:
        col_flags[j] = 0

for i in range(H):
    if not row_flags[i]:
        continue
    for j in range(W):
        if not col_flags[j]:
            continue
        print(grid[i][j], end="")
    print()

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

arr=[]
arr2=[]
for i in a:
  if '
    arr.append(i)
    
ar = np.array(arr)
arT = ar.T
 
for i in arT:
  if '
    arr2.append(i)
    
arr3 = np.array(arr2)
arr4 = arr3.T
 
arr5=arr4.tolist()

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

Solution (Python):

h,w=map(int,input().split())
List=[]
List_gyou=[""]*w
ans=[]
kotae=[]

for i in range(h):
    a=input()
    check=set(a)
    if (check!={"."}):
        List.append(a)
        for j in range(w):
            List_gyou[j]+=a[j]
            
for i in range(w):
    check=set(List_gyou[i])
    if (check!={"."}):
        ans.append(List_gyou[i])

        



for i in range(len(ans[0])):
    kore=""
    for j in range(len(ans)):
        kore+=ans[j][i]
    print(kore)

Solution (Python):
import numpy as np

h,w = map(int,input().split())
a = [list(input()) for i in range(h)]
ans1 = []
ans2 = []

for i in a:
  if '
    ans1.append(i)
    
gyouretu = np.array(ans1)
gyouretuT = gyouretu.T

for i in gyouretuT:
  if '
    ans2.append(i)
    
ans = np.array(ans2)
answer = ans.T

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

Solution (Python):
h, w = map(int, input().split())
g = []
for i in range(h):
    g.append(input())
flg = [[0] * w for _ in range(h)]

for i in range(h):
    if all(c == "." for c in g[i]):
        for j in range(w):
            flg[i][j] = 1

for j in range(w):
    if all(d[j] == "." for d in g):
        for i in range(h):
            flg[i][j] = 1

res = []
for i in range(h):
    su = ""
    for j in range(w):
        if not flg[i][j]:
            su += g[i][j]
    if su:
        res.append(su)
print(*res, sep="\n")

Solution (Python):
h,w = map(int, input().split())
a = [list(input()) for _ in range(h)]
now = 0
while True:
    if ("
        now += 1
    else:
        a.pop(now)
    if (now >= len(a)):
        break

ans = [[] for _ in range(len(a))]
for i in range(w):
    f = 0
    for j in range(len(a)):
        if (a[j][i]=="
            f += 1
    if (f>0):
        for j in range(len(a)):
            ans[j].append(a[j][i])
for i in range(len(a)):
    print(''.join(ans[i]))