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())
B = []
for _ in range(H):
    line = input()
    for l in line:
        if l == "
            B.append(line)
            break;

White = []
for i in range(W):
    flag = True
    for j in range(len(B)):
        if B[j][i] == "
            flag = False
    if flag:
        White.append(i)

for i in range(len(B)):
    line = B[i]
    for i, l in enumerate(line):
        if i not in White:
            print(l,end="")
    print()

Solution (Python):
h,w=map(int,input().split())
a=[]
for i in range(h):
    arr=list(str(input()))
    if "
for i in range(w):
    if all ([a[j][i]=="." for j in range(len(a))]):
        for k in range(len(a)):
            a[k][i]=""
for i in a:
    print("".join(i))

Solution (Python):



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

a = [list(input()) for _ in range(h)]
ans = [['.']*w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if a[i][j] == '.':
            for k in range(h):
                if a[k][j] == '.':
                    continue
                else:
                    break
            else:
                for k in range(h):
                    ans[k][j] = None
            for k in range(w):
                if a[i][k] == '.':
                    continue
                else:
                    break
            else:
                for k in range(w):
                    ans[i][k] = None
        if a[i][j] == '
            ans[i][j] = '
for i in range(h):
    ans[i] = [i for i in ans[i] if i]
for i in range(h):
    if len(ans[i]) != 0:
        print(''.join(ans[i]))

Solution (Python):
import numpy as np
import sys

buf = sys.stdin.buffer
H,W = map(int,buf.readline().split())

grid = np.frombuffer(buf.read(H*(W+1)), dtype='S1').reshape((H,W+1))
grid = grid[:,:-1]

select_col = (grid == b'
select_row = (grid == b'

grid = grid[select_row, :]
grid = grid[:, select_col]
grid = grid.astype(str)

print('\n'.join(''.join(row) for row in grid))

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



wlist = []
hlist = []
harray = []
for i in range(H):
    flag = 0
    for j in range(W):
        if l[i][j] == "
            flag = 1
    if flag == 1:
        hlist.append(i)
for i in hlist:
    harray.append(l[i])
H = len(harray)

for i in range(W):
    flag = 0
    for j in range(H):
        if harray[j][i] == "
            flag = 1
    if flag == 0:
        wlist.append(i)
for i in wlist:
    for j in range(H):
        harray[j][i] = "n"

for i in harray:
    for x in i:
        if x != "n":
            print(x,end="")
    print()

Solution (Python):
a, b = map(int, input().split())
c = [True] * a
d = [True] * b
f = []
for i in range(a):
    e = input()
    g = []
    for j in range(b):
        g.append(e[j])
        if e[j] == "
            if c[i]:
                c[i] = not c[i]
            if d[j]:
                d[j] = not d[j]
    f.append(g)
for i in range(len(c)):
    if not c[i]:
        h = ""
        for j in range(len(d)):
            if not d[j]:
                h += f[i][j]
        print(h)

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

a = [ai for ai in a if set(ai) != {'.'}] 

a = ["".join([a[i][j] for i in range(len(a))]) for j in range(len(a[0]))] 



a = [ai for ai in a if set(ai) != {'.'}]

a = ["".join([a[i][j] for i in range(len(a))]) for j in range(len(a[0]))]

for ai in a:
    print(ai)

Solution (Python):
H,W = map(int, input().split())
row = []
erase = []
for i in range(H):
    r = list(input())
    count = 0
    for j in range(W):
        if r[j] == '.':
            count += 1
    if count != W:
        row.append(r)        

for k in range(W): 
    count2 = 0
    for l in range(len(row)): 
        if row[l][k] == '.':
            count2 += 1
    if count2 == len(row):
        erase.append(k)

answer = []
if len(erase) > 0:
    for m in range(len(row)):
        ans = ''
        for n in range(len(row[m])):
            if n not in erase:
                ans += row[m][n]
        answer.append(ans)
    
else:
    for p in range(len(row)):
        ans = ''
        for q in range(len(row[p])):
            ans += row[p][q]
        answer.append(ans)
    

for o in answer:
    print(o)

Solution (Python):
import numpy as np
h,w=map(int,input().split())
a=[list(input()) for _ in range(h)]
a=np.reshape(a,(h,w))
a=a[:,np.any(a=='
[print("".join(a[i])) for i in range(a.shape[0])]

Solution (Python):

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


ls = [input() for i in range(h)]
tmp = [i for i in ls if i.count('.') != w]
def t(tmp):
  ls = []
  for i in range(len(tmp[0])):
    ls.append("")
    for j in tmp:
      ls[i] += j[i]
  return ls
tmp = t(tmp)
ls = [i for i in tmp if i.count('.') != len(tmp[0])]
for i in t(ls):
  print(i)

Solution (Python):
import numpy as np

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

    for i in range(h):
        if a[i].count("
            a[i] = a[i].replace(".", "x")

    a = np.array([list(i) for i in a])
    a = a.transpose()
    a = ["".join(i) for i in a]

    for i in range(w):
        if a[i].count("
            a[i] = a[i].replace(".", "x")

    a = np.array([list(i) for i in a])
    a = a.transpose()
    a = ["".join(i) for i in a]

    for i in a:
        if i.replace("x", "") == "":
            continue
        print(i.replace("x", ""))

if __name__ == "__main__":
    main()

Solution (Python):
H, W = map(int, input().split())
a = []
for i in range(H):
    s = input()
    if s != '.'*W:
        a.append(s)
ls = []
for i in range(W):
    b = ''
    for j in range(len(a)):
        b += a[j][i]
    if b == '.'*len(a):
        ls.append(i)
ans = []
for i in range(len(a)):
    s = ''
    for j in range(W):
        if j in ls:
            continue
        else:
            s += a[i][j]
    ans.append(s)
print(*ans, sep='\n')

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

a = [ai for ai in a if set(ai) != {'.'}]
a = ["".join([a[i][j] for i in range(len(a))]) for j in range(len(a[0]))]
a = [ai for ai in a if set(ai) != {'.'}]
a = ["".join([a[i][j] for i in range(len(a))]) for j in range(len(a[0]))]

for ai in a:
    print(ai)

Solution (Python):
h, w = map(int, input().split())
r = [list(input()) for i in range(h)]
for i in range(h):
    if not '
        r[i] = 'Nan'
r = [i for i in r if i != 'Nan']
l = list(map(list, zip(*r)))
for i in range(len(l)):
    if not '
        l[i] = 'Nan'
l = [i for i in l if i != 'Nan']
l = list(map(list, zip(*l)))
for i in range(len(l)):
    print(''.join(l[i]))

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

index_h = []
index_w = []

for i in range(H):
    for j in range(W):
        if maze[i][j] == '
            break
        if j == W - 1:
            index_h.append(i)

for j in range(W):
    for i in range(H):
        if maze[i][j] == '
            break
        if i == H - 1:
            index_w.append(j)


for i in range(H):
    flag = True
    for j in range(W):
        if i in index_h:
            flag = False
            break
        if j in index_w:
            continue
        print(maze[i][j], end='')
    if flag:
        print()

Solution (Python):
h, w = list(map(int, input().split()))
a = []
b = [0 for i in range(w)]
for i in range(h):
	ai = list(input())
	a.append(ai)
	for j in range(w):
		if b[j] == 0:
			if ai[j] == "
				b[j] = 1
ans = []
for li in a:
	if li == ["." for i in range(w)]:
		h -= 1
	else:
		ans.append(li)
wd = w
ipl = -1
for i in range(w):
	ipl += 1
	if b[i] == 0:
		wd -= 1
		for j in range(h):
			ans[j].pop(ipl)
		ipl -= 1
w = wd
for i in range(h):
	strp = ""
	for j in range(w):
		strp += ans[i][j] 
	print(strp)

Solution (Python):
import numpy as np
h, w = map(int, input().split())

amap = []

for _ in range(h):
  a = input()
  if "
    amap.append(a)

bmap = []

for wid in range(w):
  b = [amap[hei][wid] for hei in range(len(amap))]
  if "
    bmap.append(b)

bmap = np.array(bmap)
tbmap = bmap.T

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

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

B = []
for h in range(H):
    if A[h].count('.') != W:
        B.append(A[h])

for c in range(W-1, -1, -1):
    for r in range(len(B)):
        if B[r][c] != '.':
            break
    else:
        for r in range(len(B)):
            del B[r][c]

for r in range(len(B)):
    print(''.join(B[r]))

Solution (Python):
import numpy as np
h,w = map(int,input().split())
lst = []
ans = []
for i in range(h):
    s = input()
    tmp = s.replace('.','')
    if tmp:
        lst.append(list(s))
matrix = np.array(lst)
matrix = matrix.T
for i in range(w):
    s = ''.join(matrix[i])
    tmp = s.replace('.','')
    if tmp:
        ans.append(list(s))
matrix2 = np.array(ans)
matrix2 = matrix2.T
for j in matrix2:
    s = ''.join(j)
    print(s)

Solution (Python):
h,w = map(int,input().split())
masu = [input() for i in range(h)]
masu = [i for i in masu if i != "."*w]
Tmasu =[]
for j in range(w):
    x = [s[j] for s in masu]
    Tmasu.append("".join(x))
Tmasu = [i for i in Tmasu if i != "."*len(masu)]
ans = []
for k in range(len(masu)):
    x = [s[k] for s in Tmasu]
    ans.append("".join(x))
for l in ans:
    print(l)

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

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

list_h = []
for i in range(len(a)):
    if '
        list_h.append(i)

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

for i in range(len(a)):
    if i not in list_h:
        for j in range(len(a[0])):
            if j not in list_w:
                print(a[i][j], end='')
        else:
            print('')

Solution (Python):

H, W = map(int, input().split())
a = [input() for _ 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 = [list(input()) for _ in range(h)]

tate = [False] * h
yoko = [False] * w

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

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

Solution (Python):
h, w = list(map(int, input().split()))
a = [input() for i in range(h)]
x, y = [], []
for i in range(h):
  f = True
  for j in range(w):
    if a[i][j]=="
      f = False
  if f:
    y.append(i)
for j in range(w):
  f = True
  for i in range(h):
    if a[i][j]=="
      f = False
  if f:
    x.append(j)
for i in range(h):
  if i in y:
    continue
  for j in range(w):
    if j in x:
      continue
    print(a[i][j], end="")
  print()

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

while b in a:
    a.remove(b)

for i in range(w):
    flag = True
    for j in a:
        if j[i] == '
            flag = False
            break
    if flag:
        for j in a:
            j[i] = ''

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

Solution (Python):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

H, W = nl()

mas = []
for i in range(H):
    row = s()
    if row == '.' * W:
        continue
    mas.append(row)

rmas = ['' for i in range(W)]
for row in mas:
    for i in range(W):
        rmas[i] += row[i]

res = []
for row in rmas:
    if row == '.' * len(mas):
        continue
    res.append(row)

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

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


for hi in range(h):
    row = [s for s in input()]
    
    if row.count('.') == w:
        continue
    else:
        ans.append(row)


removeindex = []
for wi in range(w):
    blnRem = True
    for row in ans:
        if row[wi] == '
            blnRem = False
            break
    if blnRem:
        removeindex.append(wi)


for row in ans:
    for i, col in enumerate(row):
        if i in removeindex:
            continue
        print(col, end='')
    print()

Solution (Python):
H, W = map(int, input().split())
a = [list(input()) for _ in range(H)]
yoko = [True if "
b = [list(x) for x in zip(*a)]
tate = [True if "
for j in range(H):
    for i in range(W):
        if yoko[j] and tate[i]:
            print(a[j][i], end="")
    if yoko[j]:
        print()

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

a_list = [list(input()) for i in range(H)]
result = a_list[:]
for i,aa in enumerate(a_list):
    if aa.count('.') == len(aa):
        result[i] = 1
result = [r for r in result if r != 1]


import numpy as np
T_result = np.array(result).T
result2 = T_result.tolist()
for i, aa in enumerate(result2):
    if aa.count('.') == len(aa):
        result2[i] = 1

result2 = [r for r in result2 if r != 1]
for r2 in np.array(result2).T.tolist():
    print(''.join(r2))

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

temp = [list(map(int,input().replace("

cnt = 0


while cnt != 2:
    ans = []
    s = 0
    for row in temp:
        if sum(row) != 0:
            ans.append(row)
        else:
            s += 1
    if s == 0:
        cnt += 1
    else:
        cnt = 0
        
            
    temp = []
    for row in zip(*ans):
        temp.append(row)
    
    ans = []
    s = 0
    for row in temp:
        if sum(row) != 0:
            ans.append(row)
        else:
            s += 1
    if s == 0:
        cnt += 1
    else:
        cnt = 0
            
    temp = []
    for row in zip(*ans):
        temp.append(row)


for row in temp:
    res = list(map(str,row))
    res = ",".join(res).replace("1","
    print("".join(res))

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

A = [list(input()) for _  in range(H)]
h = set()
w = set()

for i in range(H):
    for j in range(W):
        if A[i][j] == '
            h.add(i)
            w.add(j)

for i in h:
    for j in w:
        print(A[i][j], end="")
    print()

Solution (Python):
h, w = map(int, input().split())
a = [''] * h
for i in range(h):
	a[i] = input()
 
row = [False] * h
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):
def transpose(A):
    B = []
    for j in range(len(A[0])):
        C = [A[i][j] for i in range(len(A))]
        B.append(C)
    return B

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

for i in reversed(range(H)):
    if A[i] == ['.']*W:
        A.pop(i)
        
H = len(A)        
A = transpose(A)
for j in reversed(range(W)):
    if A[j] == ['.']*H:
        A.pop(j)

A = transpose(A)
for i in range(len(A)):
 	print(*A[i], sep='')

Solution (Python):
h,w=map(int,input().split())
a=[]
k=[]
for _ in range(h):
  s=input()
  if '
    a.append(s)
l=len(a)
for i in range(w):
  for j in range(l):
    if a[j][i]=='
      k.append(i)
      break
m=max(k)
for i in range(l):
  for j in k:
    if j==m:
      print(a[i][j])
    else:
      print(a[i][j],end="")

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

aT = list(zip(*a))
aT = [x for x in aT if '
ans = list(zip(*aT))

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

Solution (Python):
def abc():
    h, w = map(int, input().split())
    lines = []
    for i in range(h):
        line = list(input().rstrip())
        if '
            lines.append(line)

    for x in reversed(range(w)):
        if len([l for l in lines if l[x] == '
            for l in lines:
                l.pop(x)
    for line in lines:
        print(''.join(line))


abc()

Solution (Python):
h, w = map(int, input().split())
a = [list(input()) for i in range(h)]
del_list = []
n = 0
for i in range(h):
    for j in range(w):
        if a[i][j] == "
            break
    else:
        del_list.append(i)
for i in reversed(del_list):
    del a[i]
del_list = []
for j in range(len(a[0])):
    for i in range(len(a)):
        if a[i][j] == "
            break
    else:
        del_list.append(j)
for j in reversed(del_list):
    for i in range(len(a)):
        del a[i][j]
for i in range(len(a)):
    ans = ""
    for j in range(len(a[0])):
        ans += a[i][j]
    print(ans)

Solution (Python):

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




def delete_row(mp):
  new_mp = []
  for row in mp:
    if ("
      new_mp.append(row)
  return len(new_mp) < len(mp), new_mp


def delete_column(mp):
  new_mp = []

  
  allow_columns = [0 for _ in range(len(mp[0]))]
  for row in mp:
    for cell_idx in range(len(row)):
      if (row[cell_idx] == "
        allow_columns[cell_idx] = 1

  for row in mp:
    allow_row = []
    for cell_idx in range(len(row)):
      if (allow_columns[cell_idx] == 1):
        allow_row.append(row[cell_idx])
    new_mp.append(allow_row)

  return 0 in allow_columns, new_mp

deleted = True
while(deleted):
  deleted, mapping = delete_row(mapping)
  deleted, mapping = delete_column(mapping)

answer = mapping


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

Solution (Python):
h,w=map(int, input().split())
s=[list(input()) for i in range(h)] 
x=0
v=0
count=0
for i in range(h):
    if s[x].count('.')==w:
        del s[x] 
    else:
        x+=1
for j in range(w):
    for i in range(len(s)):
        if s[i][v]=='.':
            count+=1
    if count==len(s):
        count=0
        for i in range(len(s)):
            del s[i][v]
    else:
        v+=1
        count=0
        
for i in range(len(s)):
    print(''.join(s[i]))

Solution (Python):

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

a = []

for i in range(H):

    newa = input()
    newa_l = list(newa)
    a.append(newa_l)

bigbul = True
while bigbul:

    bigbul = False
    acp = a.copy()
    
    for i in range(H):
    
        bul = True
        for j in range(W):

            if a[i][j] != ".":
                bul = False
                break

        if bul:
            del acp[i]
            a = acp.copy()
            H -= 1
            bigbul = True
            break

bigbul = True
while bigbul:

    bigbul = False
    acp = a.copy()

    

    for j in range(W):

        bul = True

        for i in range(H):

            if a[i][j] != ".":
                bul = False
                break


        if bul:

            for k in acp:

                del k[j]
                

                
                    
                    

            a = acp.copy()
            W -= 1
            bigbul = True
            break

for i in a:
    ans = "".join(i)
    print (ans)

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

flag_row = [True] * H
flag_col = [True] * W

for i in range(H):
    cnt = 0
    for j in range(W):
        if a[i][j] == '.':
            cnt += 1
    if cnt == W:
        flag_row[i] = False

for j in range(W):
    cnt = 0
    for i in range(H):
        if a[i][j] == '.':
            cnt += 1
    if cnt == H:
        flag_col[j] = False

for i in range(H):
    for j in range(W):
        if flag_row[i] == True and flag_col[j] == True:
            print(a[i][j], end='')
    if flag_row[i] == True:
        print()

Solution (Python):
import numpy as np
import sys

buf = sys.stdin.buffer
H,W = map(int,buf.readline().split())

grid = np.frombuffer(buf.read(H*(W+1)), dtype='S1').reshape((H,W+1))
grid = grid[:,:-1]

select_col = (grid == b'
select_row = (grid == b'

grid = grid[select_row, :]
grid = grid[:, select_col]
grid = grid.astype(str)

print('\n'.join(''.join(row) for row in grid))

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

res=[]
for i in range(h):
	a=list(input())
	if a.count('.')==w:continue
	res+=list([a]) 
col=[True]*w
for i in range(len(res)):
	for j in range(w):
		if res[i][j]=='
		
for i in range(len(res)):
	for j in range(w):
		if col[j]==False:print(res[i][j],end='')
	print()

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  h,w=LI()
  a=[]
  for _ in range(h):
    a.append(S())

  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()

main()

Solution (Python):
import numpy as np

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

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

for i in range(H):
    s = input()
    c = [j for j in range(W) if s[j] == "
    A[i][c] = 1

while True:
    
    a = A.sum(axis=0)
    if np.any(a == 0):
        del_lines = np.where(a == 0)[0]
        A = np.delete(A, del_lines, axis=1)
        continue

    
    a = A.sum(axis=1)
    if np.any(a == 0):
        del_lines = np.where(a == 0)[0]
        A = np.delete(A, del_lines, axis=0)
        continue

    
    break

A = A.tolist()
num2char = {0: ".", 1: "
for l in A:
    s = list(map(lambda x: num2char[x], l))
    print("".join(s))

Solution (Python):
h,w=map(int,input().split())
a=[]
for i in range(h):
  aa=list(input())
  if "
    continue
  else:
    a.append(aa)
aa=[]
for i in range(w):
  c=0
  for j in range(len(a)):
    if a[j][i]=="
      c+=1
  if c==0:
    aa.append(i)
aa.reverse()
for i in aa:
  for j in range(len(a)):
    del a[j][i]
for i in range(len(a)):
  print("".join(a[i]))

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

i = w-1
while i >= 0:
    col = ""
    for j in range(h):
        col += f[j][i]
    if col == "."*h:
        for j in range(h):
            del f[j][i]
    i -= 1

i = h-1
while i >= 0:
    if set(f[i]) == {"."}: del f[i];
    i -= 1

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

Solution (Python):
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

H, W = list(map(int, sys.stdin.readline().split()))
A = np.array([list(sys.stdin.readline().rstrip()) for _ in range(H)])

cols = np.array([c for c in A.T if np.any(c == '
rows = np.array([r for r in cols.T if np.any(r == '

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

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

h = []
w = []
for i in range(H):
    cnt = 0
    for j in range(W):
        if a[i][j] == '.':
            cnt += 1
    if cnt == W:
        h.append(i)

for j in range(W):
    cnt = 0
    for i in range(H):
        if a[i][j] == '.':
            cnt += 1
    if cnt == H:
        w.append(j)

for i in range(H):
    if i in h:
        continue
    for j in range(W):
        if j in w:
            continue
        print(a[i][j],end='')
    print()

Solution (Python):
H,W=map(int,input().split())
st=set()
list=list()
for i in range(H):
    S=input()
    if S.count('.') != W:
        list.append(S)
    tmp=S
    tmp=[int(i) for i,x in enumerate(tmp) if x == '.']
    if not st:
        tmp_set = set(tmp)
        st=st.union(tmp_set)
    else:
        tmp_set = set(tmp)
        st &=tmp_set
for x in list:
    str=''
    if not st:
        for i in range(W):
            str+=x[i]
    else:
        for i in range(W):
            if i not in st:
                str+=x[i]
    print(str)
    str=''

Solution (Python):
import itertools

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

grid = filter(lambda r: any(map(lambda c : c == '
grid = zip(*grid)
grid = filter(lambda r: any(map(lambda c : c == '
grid = zip(*grid)

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

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

whiteh = []
whitew = []
for i in range(h):
  if grid[i] == "."*w:
    whiteh.append(i)

for i in reversed(whiteh):
  grid.pop(i)
h -= len(whiteh)

grid2 = [""]*w
for i in range(h):
  for j in range(w):
    grid2[j] += grid[i][j]    
    
for i in range(w):
  if grid2[i] == "."*h:
    whitew.append(i)    
    
for i in reversed(whitew):
  grid2.pop(i)
w -= len(whitew)

gridans = [""]*h
for i in range(w):
  for j in range(h):
    gridans[j] += grid2[i][j] 

for i in range(h):
  print(gridans[i])

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

allwhiteh = [1] * H
allwhitev = [1] * W
for i in range(H):
    for j in range(W):
        if a[i][j] == '
            allwhiteh[i] = 0
            allwhitev[j] = 0

for i in range(H):
    for j in range(W):
        if not allwhiteh[i] and not allwhitev[j]:
            print(a[i][j], end="")
    if not allwhiteh[i]:
        print("")

Solution (Python):
H, W = map(int, input().split())
a = list(zip(*[j for j in list(zip(*[i for i in [list(input()) for _ in range(H)] if "
for n in range(len(a)):
	print("".join(a[n]))

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

a = list(zip(*[i for i in a if "
a = list(zip(*[j for j in a if "
for n in range(len(a)):
	print("".join(a[n]))

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

a = list(zip(*a))

a = [j for j in a if "

a = list(zip(*a))

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

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

b = []
def solve(ls,i,j,h,w):
	flg = 0
	for k in range(w):
		if ls[i][k] == "
			flg += 1
			break
	for l in range(h):
		if ls[l][j] == "
			flg += 1
			break
			
	if flg ==2:
		return True
	else:
		return False

			

for i in range(h):
	c = []
	for j in range(w):
		if a[i][j] == "
			c.append("
		elif solve(a,i,j,h,w):
			c.append(".")
		else:
			pass
	b.append(c)

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

Solution (Python):
h,w=map(int,input().split())
hw=[input() for i in range(h)]
thw=[]
for i in range(h):
    if hw[i].count('
        thw+=[hw[i]]
ans=['']*len(thw)
for i in range(w):
    flg=False
    for j in range(len(thw)):
        if thw[j][i]=='
            flg=True
            break
    if flg:
        for j in range(len(thw)):
            ans[j]+=thw[j][i]
for i in range(len(ans)):
    print(ans[i])

Solution (Python):
h,w = map(int, input().split())
Hli,Wli = [0 for _ in range(h)],[0 for _ in range(w)]
A = []
for i in range(h):
    l = input()
    for j in range(w):
        if l[j] == "
            Hli[i] = 1
            Wli[j] = 1
    A.append(l)

for i in range(h):
    str = ""
    for j in range(w):
        if Hli[i]*Wli[j] == 1:
            str += A[i][j]
    if str != "": print(str)

Solution (Python):
h,w= map(int, input().split())
s = []
a = []
for i in range(h):
    temp = input()
    if '
        s.append(temp)
for j in range(w):
    flag = False
    for i in s:
        if i[j] == '
            flag = True
            break
    a.append(flag)
s = ["".join(j[i] for i in range(w) if a[i]) for j in s]
 
for x in s:
    print(x)

Solution (Python):
import math
 
h,w = list(map(int, input().split()))
data = []
for i in range(h):
    a=list(map(str, input().split()))
    data.append(a[0])

hlist=[]
wlist=[]
for i in range(h):
    flag=0
    for j in range(w):
        if(data[i][j]=='
            flag=1
    if(flag==1):
        hlist.append(i)

for i in range(w):
    flag=0
    for j in range(h):
        if(data[j][i]=='
            flag=1
    if(flag==1):
        wlist.append(i)
        

for i in range(len(hlist)):
    temp=""
    for j in range(len(wlist)):
        temp+=data[hlist[i]][wlist[j]]
    print(temp)

Solution (Python):
import math
 
h,w = list(map(int, input().split()))
data = []
for i in range(h):
    a=list(map(str, input().split()))
    data.append(a[0])

hlist=[]
wlist=[]
for i in range(h):
    flag=0
    for j in range(w):
        if(data[i][j]=='
            flag=1
    if(flag==1):
        hlist.append(i)

for i in range(w):
    flag=0
    for j in range(h):
        if(data[j][i]=='
            flag=1
    if(flag==1):
        wlist.append(i)
        

for i in range(len(hlist)):
    temp=""
    for j in range(len(wlist)):
        temp+=data[hlist[i]][wlist[j]]
    print(temp)

Solution (Python):
H, W = [int(hw) for hw in input().split()]
A = []
for h in range(H):
  a = [a for a in input()]
  if a.count("
    A.append(a)

for w in reversed(range(W)):
  cnt = 0
  for h in range(len(A)):
    if A[h][w] == ".":
      cnt += 1
  if cnt == len(A):
    for h in range(len(A)):
      del A[h][w]

for h in range(len(A)):
  ans = "".join(A[h])
  print(ans)

Solution (Python):
import numpy as np

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

ret = []
for r in grid:
    if any(x == '
        ret.append(r)
grid = np.array(ret).T.tolist()

ret = []
for r in grid:
    if any(x == '
        ret.append(r)

grid = np.array(ret).T.tolist()

for r in grid:
    print(*r, sep='')