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 = [input() for _ in range(H)]
B = [A[h] for h in range(H) if '

rem = []
for w in range(W):
    col = [B[i][w] for i in range(len(B))]
    if '
        rem.append(w)

for h in range(len(B)):
    for w in range(W):
        if w not in rem:
            print(B[h][w], end="")
    print()

Solution (Python):
h,w=map(int,input().split())
a=[input() for i in range(h)]
b=[i for i in a if i.count("
for i in range(w-1,-1,-1):
    if sum([b[j][i]=="
        for k in range(len(b)):
            b[k]=b[k][:i]+b[k][i+1:]
print(*b,sep="\n")

Solution (Python):
H,W = map(int,input().split())
A = []
for h in range(H):
    a = input()
    if '
        A.append(a)
A = [a for a in zip(*A) if '
A = [a for a in zip(*A)]
for a in A:
    print(''.join(a))

Solution (Python):
H,W = map(int,input().split())
A = [list(input()) for h in range(H)]
A = [a for a in A if '
A = [a for a in zip(*A) if '
A = [a for a in zip(*A)]
for a in A:
    print(''.join(a))

Solution (Python):
H,W = map(int, input().split())
A = [input() for h in range(H)]
A = [list(a) for a in A if '
w = 0
while w < W:
    for a in A:
        if a[w]=='
            break
    else:
        for a in A:
            a.pop(w)
        W -= 1
        w -= 1
    w += 1
for a in A:
    print(''.join(a))

Solution (Python):
h, w = map(int, input().split())
a = []
for _ in range(h):
    l = input()
    if l != '.'*w:
        a.append(l)
col = []
h = len(a)
for i in range(w):
    if a[0][i] == '.':
        for j in range(1,h):
            if a[j][i] != '.':
                col.append(i)
                break
    else:
        col.append(i)
for l in a:
    ll = ''
    for i in col:
        ll += l[i]
    print(ll)

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

y = []
for i, name in enumerate(n):
    if not all([j == "." for j in name]):
        y.append(name)

nc = []
for _ in range(len(y[0])):
    nnc = []
    for _ in range(len(y)):
        nnc.append("
    nc.append(nnc)

for i, name in enumerate(y):
    for k, name2 in enumerate(name):
        nc[k][i] = name2

z = []
for i, name in enumerate(nc):
    if not all([j == "." for j in name]):
        z.append(name)

nc = []
for _ in range(len(z[0])):
    nnc = []
    for _ in range(len(z)):
        nnc.append("
    nc.append(nnc)

for i, name in enumerate(z):
    for k, name2 in enumerate(name):
        nc[k][i] = name2

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

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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

ansX = []
ansY = []

for y in range(h):
    flag = True
    for x in range(w):
        if (a[y][x] == '
            flag = False
    if (flag):
        ansY.append(y)

for x in range(w):
    flag = True
    for y in range(h):
        if (a[y][x] == '
            flag = False
    if (flag):
        ansX.append(x)

for y in range(h):
    if (y in ansY):
        continue
    for x in range(w):
        if (x in ansX):
            continue
        print(a[y][x], end='')
    print('')

Solution (Python):
h,w = map(int, input().split())
a = [input() for i in range(h)]
a = [i for i in a if i!="."*w]
import numpy as np
flag = [[int(j) for j in i.replace(".","0").replace("
flagx = np.sum(flag,axis=0) > 0
d = {0:".",1:"
for i in a:
  for j,b in zip(i,flagx):
    if b:
      print(j, end="")
  print()

Solution (Python):

def main():
    H, W, *A = open(0).read().split()
    H, W = int(H), int(W)
    X, Y = [0] * H, [0] * W
    for i, a in enumerate(A):
        for j, x in enumerate(a):
            if x == "
                X[i], Y[j] = 1, 1
    ans = []
    for i, x in enumerate(X):
        cur = ""
        for j, y in enumerate(Y):
            if x and y:
                cur += A[i][j]
        if cur:
            ans.append(cur)
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()

Solution (Python):
H, W = map(int, input().split())
matrix = [list(input()) for j in range(H)]
A = []
for line in range(H):
    if matrix[line].count('.') != W:
        A.append(matrix[line])
B = [] 
for row in range(W):
    flg = True
    for line in range(len(A)):
        if A[line][row] == '
            flg = False
    if flg == True:
        B.append(row)
C = [] 
for line in range(len(A)):
    for b in sorted(B, reverse=True):
        A[line].pop(b)
    C.append(A[line])
for c in C:
    print(''.join(c))

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

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

B = [] 
for row in range(W):
    flg = True
    for line in range(len(A)):
        if A[line][row] == '
            flg = False
    if flg == True:
        B.append(row)

C = []
for line in range(len(A)):
    for b in sorted(B, reverse=True):
        A[line].pop(b)
    C.append(A[line])
for c in C:
    print(''.join(c))

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


b=[]
for i in range(H):
  if sum(a[i])!=0:
    b.append(a[i])


c=[]
for j in range(W):
  cnt=0
  for i in range(len(b)):
    cnt+=b[i][j]
  c.append(cnt)


d=[]
for i in range(len(b)):
  dd=[]
  for j in range(W):
    if c[j]!=0:
      dd.append(b[i][j])
  d.append(dd)


for i in range(len(d)):
  print("".join(list(map(lambda x: "." if x==0 else "

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

import copy

H,W = map(int,input().split())
a = [list(input().split()) for _ in range(H)]
for i in range(H):
    a[i] = list(a[i][0])
a_copy = copy.copy(a)
ans = [[] for _ in range(H)]
h=0
for i in range(H):
    Flag = True
    for j in range(W):
        if a[i][j] != ".":
            Flag = False
            break
    if not(Flag):
        for j in range(W):
            ans[h].append(a[i][j])
        h+=1
ans_H=h

ans2 = [[] for _ in range(H)]

for i in range(W):
    Flag = True
    for j in range(ans_H):
        if ans[j][i] != ".":
            Flag = False
            break
    if not(Flag):
        for j in range(ans_H):
            ans2[j].append(ans[j][i])


for i in range(ans_H):
    print("".join(ans2[i]))

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

Solution (Python):
import os, sys, re, math

def dorow(N):
    cnt = 0
    for i in range(1, N+1):
        if N % i == 0:
            cnt += 1
    return cnt

H,W = map(int,input().split(' '))
table = []
for h in range(H):
    tmp = input()
    if tmp != '.' * W:
        table.append(tmp)

ret = ['' for _ in range(len(table))]

for i in range(W):
    flg = False
    for j in range(len(table)):
        if table[j][i] == '
            flg = True
            break

    if flg:
        for j in range(len(table)):
            ret[j] += table[j][i]

for r in ret:
    print(r)

Solution (Python):
import os, sys, re, math

(H, W) = [int(i) for i in input().split()]
a = []
for i in range(H):
    r = input()
    if '
        a.append(r)

a = [''.join(r) for r in zip(*a)]
a = filter(lambda r: '
a = [''.join(r) for r in zip(*a)]

for r in list(a):
    print (r)

Solution (Python):
line = raw_input()
H, W = [int(s) for s in line.split(' ')]
lines = []
ret = [0] * W
for h in range(0, H):
    line = raw_input()
    A = [0 if s == '.' else 1 for s in line]
    if all([a == 0 for a in A]):
        continue
    lines.append(line)
    ret = [i + j for i, j in zip(ret, A)]
for line in lines:
    print ''.join([c for i, c in zip(range(0, W), line) if ret[i] > 0])

Solution (Python):
N, K = list(map(int, input().split(' ')))
ll = []
for i in range(N):
    l = [c != '.' for c in input()]
    if (any(l)):
        ll.append(l)
tll = [list(x) for x in zip(*ll)]
tans = []
for i in range(len(tll)):
    if (any(tll[i])):
        tans.append(tll[i])
        
ans = [list(x) for x in zip(*tans)]
for i in range(len(ans)):
    print(''.join(['

Solution (Python):
H,W=map(int,input().split())
A=[list(input()) for i in range(H)]
B=[]
C=[]
ans=[]
for i in range(H):
  if '
    B.append(A[i])
C=list(zip(*B))
for i in range(W):
  if '
    ans.append(C[i])
ans=list(zip(*ans))
for k in range(len(ans)):
  print(*ans[k],sep='')

Solution (Python):
h,w=map(int,input().split())
*l,=eval("input(),"*h)
row=[any(l[i][j]=="
col=["
for i in range(h):
	f=0
	for j in range(w):
		if row[j]&col[i]:
			print(l[i][j],end="")
			f=1
	if f:
		print("")

Solution (Python):
h,w=map(int,input().split())
a=[input() for i in range(h)]
b=[]
c=[]
ans=[]
for i in range(h):
    if "
        b.append(a[i])
c=list(zip(*b))
for j in range(w):
    if "
        ans.append(c[j])
ans=list(zip(*ans))
for k in range(len(ans)):
    print(*ans[k],sep='')

Solution (Python):
n, m = map(int,input().split())
h,w= [],[]
a = [list(input()) for i in range(n)]
b = [i for i in zip(*a)]
for i in range(n):
    if a[i].count(".") == len(a[i]):
        h.append(i)

h = sorted(h,reverse=True)
while h:
    del a[h[0]]
    del h[0]

for i in range(m):
    if b[i].count(".") == len(b[i]):
        w.append(i)

w = sorted(w,reverse=True)
while w:
    for i in range(len(a)):
        del a[i][w[0]]
    del w[0]

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

Solution (Python):
H, W = map(int, input().split())
A = [input() for i in range(H)]
B = []
for a in A:
    if not all([x == '.' for x in a]):
        B.append(a)
C = zip(*[b for b in zip(*B) if '
for c in C:
    print(*c, sep='')

Solution (Python):
H, W = map(int, input().split())
a = [input() for i in range(H)]
b = []
for i in range(H):
    if '
        b.append(a[i])
        
ans = zip(*[i for i in zip(*b) if '
 
for j in ans:
    print(*j, sep='')

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


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


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

Solution (Python):
h, w = map(int, input().split())
a = [tuple(input()) for _ in range(h)]
b = [b for b in a if "
c = zip(*[c for c in zip(*b) if "
for d in c: print(*d, sep="")

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

x=[False]*w
y=[False]*h

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


for i in range(h):
    li=[]
    for j in range(w):
        if x[j]==True and y[i]==True:
            li+=a[i][j]
    if li!=[]:
        print(''.join(li))

Solution (Python):
h, w = map(int, input().split())
ls = [input().strip() for _ in range(h)]
ls = [l for l in ls if l.count('.') < w]


def transpose(ls):
    res = []
    h = len(ls)
    w = len(ls[0])
    for j in range(w):
        l = ''
        for i in range(h):
            l += ls[i][j]
        res.append(l)
    return res


h = len(ls)
ls = transpose([l for l in transpose(ls) if l.count('.') < h])

print(*ls, sep='\n')

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

for h in range(H): 
  f = True
  for w in range(W):
    if A[h][w] != ".":
      f = False
  if not f:
    Hlist.append(h)
for w in range(W): 
  f = True
  for h in range(H):
    if A[h][w] != ".":
      f = False
  if not f:
    Wlist.append(w)

Aout = []

for h in Hlist:
  a = ""
  for w in Wlist:
    a += A[h][w]
  Aout.append(a)

for aout in Aout:
  print(aout)

Solution (Python):
import numpy as np

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

for z in zentai[:]:
  if "
    zentai.remove(z)

tr=np.array(zentai)
tr=tr.T
tr=tr.tolist()

for z in tr[:]:
  if "
    tr.remove(z)

tr=np.array(tr)
tr=tr.T
tr=tr.tolist()

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

Solution (Python):
H,W=map(int,input().split())
A=[[i for i in input()] for _ in range(H)]
B=[x for x in A if '
C=zip(*[y for y in zip(*B) if '
for d in C:
  print(''.join(d))

Solution (Python):
h,w = map(int,input().split())
A = [list(input()) for i in range(h)]
White_rows = []
for i in range(h):
    if A[i] == ['.' for j in range(w)]:
        White_rows += [i]
White_rows.sort(reverse=True)
for row in White_rows:
    A.pop(row)
White_cols = []
for i in range(w):
    if all([A[j][i] == '.' for j in range(len(A))]):
        White_cols += [i]
White_cols.sort(reverse=True)
for col in White_cols:
    for j in range(len(A)):
        A[j].pop(col)
for a in A:
    print(*a,sep='')

Solution (Python):
H,W=map(int,input().split())
grid=[""]*H
del_list=[[],[]]
for i in range(H):
  grid[i]=list(input())
  if grid[i]==["." for j in range(W)]:
    del_list[0].append(i)

for i in range(W):
  tmp=[grid[x][i] for x in range(H)]
  if tmp == ["." for j in range(H)]:
    del_list[1].append(i)
    
for i in reversed(range(len(del_list[0]))):
  grid.pop(del_list[0][i])
  
for i in reversed(range(len(del_list[1]))):
  for j in range(len(grid)):
    grid[j].pop(del_list[1][i])

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

Solution (Python):
def tenchi(gr):
    gr_t=[[0]*len(gr) for i in range(len(gr[0]))]
    for i in range(len(gr)):
        for j in range(len(gr[i])):
            gr_t[j][i] = gr[i][j]
    return gr_t

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

while a.count(["."]*len(a[0]))>0:
    a.remove(["."]*len(a[0]))

a_t = tenchi(a)
while a_t.count(["."]*len(a_t[0]))>0:
    a_t.remove(["."]*len(a_t[0]))
ans = tenchi(a_t)
for i in range(len(ans)):
    ansa = "".join(ans[i])
    print(ansa)

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())
maze = []

for _ in range(H):
    s = list(input())
    if s != ["."]*W:
        maze.append(s)
maze = np.array(maze)

undels = []
for i in range(maze.shape[1]):
    if sum(maze[:, i] == ".") != maze.shape[0]:
        undels.append(i)
ans = maze[:, undels]
for i in range(ans.shape[0]):
    print(*ans[i], sep="")

Solution (Python):
H, W = map(int, input().split())
grid = []
for i in range(H):
    g = input()
    if '
        grid.append(g)
        
ans = zip(*[i for i in zip(*grid) if '

for j in ans:
  print(*j, sep='')

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

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



dl = []

for i in range(h):
    if all(j =='.' for j in m[i]):
        dl.append(int(i))

if dl:
    for i in dl:
        del m[i-dl.index(i)]
h = len(m)


dl = []
for i in range(w):
    s = ''
    for j in range(h):
        s = s + m[j][i]
    if all(j == '.' for j in list(s)):
        dl.append(int(i))

if dl:
    for i in range(h):
        for j in dl:
            del m[i][j-dl.index(j)]


for i in range(h):
    print(''.join(m[i]))

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 i in range(H)]
ans = []
for i in range(H):
    flag = 0
    for j in range(W):
        if A[i][j] == "
            flag = 1
    if flag == 1:
        ans.append(A[i])
H2 = len(ans)
W2 = len(ans[0])
ans2 = []
for j in range(W2):
    flag = 0
    for i in range(H2):
        if ans[i][j] == "
            flag = 1
    if flag == 1:
        ans2.append(j)
Ans = []  
for i in range(H2):
    Ans.append([])
    for j in ans2:
        Ans[i].append(ans[i][j])
        
W3 = len(Ans[0])
for i in range(H2):
    tmp = ""
    for j in range(W3):
        tmp += Ans[i][j]
    print(tmp)

Solution (Python):
h,w=map(int,input().split())
a=[]
for i in range(h):
    tmp=str(input())
    if '
        a.append(tmp)
delete=[-1]
for i in range(w):
    for j in range(len(a)):
        if a[j][i]=='
            break
        else:
            if j==len(a)-1:
                delete.append(i)
if delete==[]:
    delete.append(w)
for i in range(len(a)):
    for j in range(1,len(delete)):
        print(a[i][delete[j-1]+1:delete[j]],end="")
    if delete[-1]<w-1:
        print(a[i][(delete[-1]+1):],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):
h,w = map(int,input().split())
A = [list(input()) for _ in range(h)]
B = []
C = []
for Row in A:
    if set(Row)!={'.'}: B.append(Row)
B = [Row for Row in zip(*B)]
for Row in B:
    if set(Row)!={'.'}: C.append(Row)
for Row in zip(*C):
    print(''.join(Row))

Solution (Python):
h, w = map(int, input().split())
a = []
for _ in range(h):
    l = input()
    if l != '.'*w:
        a.append(l)
col = []
h = len(a)
for i in range(w):
    if a[0][i] == '.':
        for j in range(1,h):
            if a[j][i] != '.':
                col.append(i)
                break
    else:
        col.append(i)
for l in a:
    ll = ''
    for i in col:
        ll += l[i]
    print(ll)

Solution (Python):
H, W = map(int, input().split())
A = []
for i in range(H):
  As = input()
  if As.find("
    H -= 1
  else:
    A.append(As)
j = 0
while j < W:
  b = True
  for As in A:
    if As[j] == "
      b = False
  if b:
    W -= 1
    for i in range(len(A)):
      A[i] = A[i][:j]+A[i][j+1:]
  else:
    j += 1
for i in range(H):
  As = A[i]
  print(As)

Solution (Python):
H,W=map(int,input().split())
grid=[input() for i in range(H)]
h=[]
w=[]
for i in range(H):
    for j in range(W):
        if grid[i][j]=='
            h.append(i)
            w.append(j)
h=list(set(h))
w=list(set(w))
for i in h:
    p=''
    for j in w:
        p+=grid[i][j]
    print(p)

Solution (Python):
H,W=map(int,input().split())
g=''
g2=''
h_removed=0
w_removed=0
for i in range(H):
    ip=input()
    if ip=='.'*W:
        h_removed+=1
    else:
        g+=ip
        
for i in range(W):
    col=''
    for j in range(H-h_removed):
        col+=g[i+j*W]
    if col=='.'*(H-h_removed):
        w_removed+=1
    else:
        g2+=col
        
for i in range(H-h_removed):
    p=''
    for j in range(W-w_removed):
        p+=g2[i+j*(H-h_removed)]
    print(p)

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

a=[list(input()) for i in range(H)]
l_idx=[]
c_idx=[]
for i in range(H):
    for j in range(W):
        if a[i][j]=="
            l_idx.append(i)
            c_idx.append(j)

for i in range(W-1,-1,-1):
    if not i in c_idx:
        for j in range(H):
            a[j].pop(i)

for i in range(H):
    if i in l_idx:
        print("".join(a[i]))

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

a=[list(input()) for i in range(H)]
l_idx=[]
c_idx=[]
for i in range(H):
    for j in range(W):
        if a[i][j]=="
            l_idx.append(i)
            c_idx.append(j)

for i in range(W-1,-1,-1):
    if not i in c_idx:
        for j in range(H):
            a[j].pop(i)

for i in range(H):
    if i in l_idx:
        print("".join(a[i]))

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

for i in range(W):
    cnt=0
    for j in range(1,H):
        if a[0][i]=="." and a[0][i]==a[j][i]:
            cnt+=1
            if cnt==H-1:
                rmidx.append(i)
        else:
            break


for i in range(H):
    for j in reversed(rmidx):
        a[i].pop(j)

rmidx=[]

for i in range(H):
    if a[i].count("
        rmidx.append(i)

for i in range(H):
    if not i in rmidx:
        print("".join(a[i]))

Solution (Python):

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

h_d = []
for i in range(h):
    cnt = 0
    for j in range(w):
        if a[i][j] != '.':
            break
        cnt += 1
    if cnt == w:
        h_d.append(i)
a = [a[i] for i in range(h) if i not in h_d]

h_ = len(a)
w_d = []
for j in range(w):
    cnt = 0
    for i in range(h_):
        if a[i][j] != '.':
            break
        cnt += 1
    if cnt == h_:
        w_d.append(j)
a = [[a[j][i] for i in range(w) if i not in w_d]for j in range(h_)]

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

Solution (Python):
H,W=map(int,input().split())
A=[]
for _ in range(H):
    a=list(input())
    if sum(list(map(ord, a)))==ord(".")*W:
        continue
    A.append(a)

B=[]
for a in zip(*A):
    if sum(list(map(ord, a)))==ord(".")*len(a):
        continue
    B.append(a)

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

Solution (Python):

import sys


def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

H, W = ISI()
a = [[j for j in IS()] for i in range(H)]
b = []
for x in a:
    if "
        b.append(x)
c = []
for y in zip(*b):
    if "
        c.append(y)
for a in zip(*c):
    print("".join(a))

Solution (Python):
h, w = map(int, input().split())
a = []
for _ in range(h):
    _a = list(input())
    if '
        a += [_a]
    else:
        pass

import numpy as np

a = np.array(a)
ans_col = []

for i in range(w):
    if '
        ans_col += [i]
    else:
        pass

ans = a[:, ans_col]

for j in range(a.shape[0]):
    print(''.join(map(str, ans[j, :])))

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

for i in range(h):
  j = list(input())
  if '
    a.append(j)
    
ans = zip(*[i for i in zip(*a) if '

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

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

a1 = []
for h_i in range(h):
    if "
        a1.append(a[h_i])

a2 = []
for w_i in range(w):
    for h_i in range(len(a1)):
        if a1[h_i][w_i] == "
            break
    else:
        a2.append(w_i)

for i in range(len(a2)):
    a2[i] -= i

for ele in a2:
    for h_i in range(len(a1)):
        a1[h_i].pop(ele)

for h_i in range(len(a1)):
    print("".join(a1[h_i]))

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

A_int = []
for a in A:
  temp = []
  for i in range(W):
    if a[0][i] == '.':
      temp.append(0)
    else:
      temp.append(1)
  if sum(temp)>0:
    A_int.append(temp)

import numpy as np
A = np.array(A_int)
del_columns=[]
for i in range(len(np.all(A==0, axis=0))):
  if np.all(A==0, axis=0)[i]==True:
    del_columns.append(i)
A_del = np.delete(A, del_columns, axis=1)

for i in range(A_del.shape[0]):
  ans=""
  for j in range(A_del.shape[1]):
    if A_del[i][j]==0:
      ans += "."
    else:
      ans += "
  print(ans)

Solution (Python):
h, w = map(int, input().split())
maplist = []
h2 = h
for i in range(h):
    k = [x for x in input()]
    for j in range(len(k)):
        if k[j] == "
            maplist.append(k)
            break
        if j == len(k)-1:
            h2 -= 1
deletelist = []
for i in range(w):
    for j in range(h2):
        if maplist[j][i] == "
            break
        if j == h2-1:
            deletelist.append(i)
deletelist = reversed(deletelist)
for i in deletelist:
    for j in range(h2):
        maplist[j].pop(i)
for i in range(h2):
    print("".join(maplist[i]))

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

for i in a:
    for j in range(W):
        if i[j] == '
            jud[j] += 1
        else:
            continue

b = [i for i in a if '

for i in range(len(b)):
    ans = ''
    for j in range(W):
        if jud[j] != 0:
            ans += b[i][j]
        else:
            continue
    print(ans)

Solution (Python):
H, W = map(int, input().split())
L = [list(input()) for _ in range(H)]
L1 = [x for x in L if "
L2 = [x for x in zip(*L1) if "
for t in zip(*L2):
    print(''.join(t))

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

L1 = list(filter(lambda x: ''.join(x) != '.' * W, L))
L2 = list(filter(lambda x: x.count('.') != len(L1), list(zip(*L1))))
for t in list(zip(*L2)):
    print(''.join(t))

Solution (Python):
H,W = map(int,input().split())
A = [list(input()) for i in range(H)]
A_line = ['.'] * W
de_row = []
de_column = []
s = 0
t = 0
ind = 0
for a in A:
    if a == A_line:
        de_column.append(ind)
    ind += 1
for d in de_column:
    del A[d-s]
    s += 1

for i in range(W):
    flag = 0
    for j in range(len(A)):
        if A[j][i] == '.':
            flag += 1
            if flag == len(A):
                de_row.append(i)
            continue
        else:
            break

for d in de_row:
    for i in range(len(A)):
        del A[i][d-t]
    t += 1
for a in A:
    print(''.join(a))

Solution (Python):


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

a = [[0]*w]*h
for i in range(h):
    a[i] = list(input())


a = [ai for ai in a if "".join(ai) != "."*w]


at = []
for aj in zip(*a):
    if "".join(aj) != "."*len(aj):
        at.append(aj)


for ai in zip(*at):
    print("".join(ai))

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

h, w = na()
mas = []
li = []
for i in range(h):
    col = input()
    if "
        mas.append(col)
for i in range(w):
    for j in range(len(mas)):
        if mas[j][i] == ".":
            if j == len(mas) - 1:
                li.append(i)
            continue
        else:
            break
for i in range(len(mas)):
    ans = ""
    for j in range(w):
        if j not in li:
            ans += mas[i][j]
    print(ans)

Solution (Python):
H,W = map(int,input().split())
A = []
for i in range(H):
    a = list(input())
    if a.count('.') == W:
        H -= 1
        continue
    A.append(a)

skipcol = []
for i in range(W):
    t = 0
    for j in range(H):
        if A[j][i] == '.':
            t += 1
    if t == H: skipcol.append(i)

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

Solution (Python):
H, W = map(int, input().split())
a = [list(input()) for i in range(H)]
memo = []
b = []
for i in range(H):
  if "
    memo.append(i)
for x in memo:
  b.append(a[x])
memo = []
d = []
for c in zip(*b):
  d.append(c)
for i in range(W):
  if "
    memo.append(i)
e = []
for x in memo:
  e.append(d[x])
for r in zip(*e):
  print("".join(r))

Solution (Python):
import numpy as np

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

a = np.empty(0,dtype=np.unicode)
for i in range(h):
    a = np.append(a,[x for x in input()])

a = np.reshape(a,(h,w))
a = a[:,np.any(a == '
a = a[np.any(a == '

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

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

for i in range(h-1,-1,-1):
    if "
        del l[i]
z = list(zip(*l))

for i in range(len(z)-1,-1,-1):
    if "
        for j in range(len(l)):
            del l[j][i]
            
for i in range(len(l)):
    print("".join(l[i]))

Solution (Python):
import numpy as np
h,w=map(int,input().split())
a=np.array([list(input()) for i in range(h)])
c=0
for j in range(h,0,-1):
    if all([k=='.' for k in a[j-1,:]]):
        a=np.delete(a,j-1,0)
        c+=1
for l in range(w,0,-1):
    if all([n=='.' for n in a[:,l-1]]):
        a=np.delete(a,l-1,1)
for m in range(h-c):
    print(''.join(a[m,:]))

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

updated = True
while updated:
    updated = False
    newA = []
    for i in range(len(A)):
        if len(set(A[i])) == 1 and A[i][0] == '.':
            updated = True
        else:
            newA.append(A[i])
    A = newA
    newA = []
    for j in range(len(A[0])):
        tmp = [A[i][j] for i in range(len(A))]
        if len(set(tmp)) == 1 and A[0][j] == '.':
            updated = True
        else:
            newA.append(tmp)
    A = [['.' for j in range(len(newA))] for i in range(len(newA[0]))]
    for i in range(len(newA)):
        for j in range(len(newA[i])):
            A[j][i] = newA[i][j]





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

Solution (Python):
import numpy as np
H, W = list(map(int, input().split()))
l = []
for h in range(H):
    l.append(list(input()))
nl = np.array(l)

t = np.all(nl == ".", axis=1)
dl = []
for i, f in zip(range(len(t) + 1), t):
    if f:
        dl.append(i)
nl = np.delete(nl, dl, axis=0)

dl = []
t = np.all(nl == ".", axis=0)
for i, f in zip(range(len(t) + 1), t):
    if f:
        dl.append(i)
nl = np.delete(nl, dl, axis=1)

for s in nl:
    print("".join(s))

Solution (Python):
h, w = map(int, input().split())
s = []
for i in range(h):
  _s = input()
  if '
    s.append(_s)
    
deletes = []
for j in range(w):
  for i in range(len(s)):
    if s[i][j] == '
      break
  else:
    deletes.append(j)
    
for i in range(len(s)):
  out = ''
  for j in range(len(s[i])):
    if not j in deletes:
      out += s[i][j]
  print(out)

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