Problem:
 Score : 200 points    Problem Statement There is a grid of squares with H horizontal rows and W vertical columns.
The square at the i -th row from the top and the j -th column from the left is represented as (i, j) .
Each square is black or white.
The color of the square is given as an H -by- W matrix (a_{i, j}) .
If a_{i, j} is . , the square (i, j) is white; if a_{i, j} is # , the square (i, j) is black.  Snuke is compressing this grid.
He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:   Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.   It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.
Find the final state of the grid.      Constraints  1 \leq H, W \leq 100  a_{i, j} is . or # .  There is at least one black square in the whole grid.         Input Input is given from Standard Input in the following format:  H  W  a_{1, 1}...a_{1, W}  :  a_{H, 1}...a_{H, W}       Output Print the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.        Sample Input 1 4 4
##.#
....
##.#
.#.#      Sample Output 1 ###
###
.##  The second row and the third column in the original grid will be removed.       Sample Input 2 3 3
#..
.#.
..#      Sample Output 2 #..
.#.
..#  As there is no row or column that consists only of white squares, no operation will be performed.       Sample Input 3 4 5
.....
.....
..#..
.....      Sample Output 3 #       Sample Input 4 7 6
......
....#.
.#....
..#...
..#...
......
.#..#.      Sample Output 4 ..#
#..
.#.
.#.
#.#

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

def resolve():
    h,w=map(int, input().split())
    l=[]
    for i in range(h):
        ll=list(input())
        l.append(ll)
    
    gyou= [False] * w
    retu= [False] * h
    for jretu in range(h):
        for kgyou in range(w):
            
            
            if l[jretu][kgyou]=='
                retu[jretu]=True
                gyou[kgyou]=True
    for jretu in range(h):
        if retu[jretu]:
            for kgyou in range(w):
                if gyou[kgyou]:
                    print(l[jretu][kgyou],end='')
            print('')
resolve()

Solution (Python):
h,w = map(int,input().split())
maze = []
for _ in range(h):
  s = input()
  if s != '.'*w:
    maze.append(s)
h = len(maze)
skip = []
for j in range(w):
  for i in range(h):
    if maze[i][j] == '
      break
  else:
    skip.append(j)
 
for i in range(h):
  for j in range(w):
    if j not in skip:
      print(maze[i][j],end= '')
  print()

Solution (Python):
h,w = map(int,input().split())
maze = []
for _ in range(h):
  s = input()
  if s != '.'*w:
    maze.append(s)
h = len(maze)
skip = []
for j in range(w):
  for i in range(h):
    if maze[i][j] == '
      break
  else:
    skip.append(j)

for i in range(h):
  for j in range(w):
    if j not in skip:
      print(maze[i][j],end= '')
  print()

Solution (Python):
H, W = map(int, input().split())
graph = [list(input()) for _ in range(H)]
def rotate_cw(graph):
    height = len(graph)
    width = len(graph[0])
    result = [[] for _ in range(width)]
    for x in range(width):
        for y in range(height - 1, -1, -1):
            result[x].append(graph[y][x])
    return result

for _ in range(max(H, W)):
    for angle in range(4):
        pop = 0
        for i in range(len(graph)):
            if "
                graph.pop(i-pop)
                pop += 1
        graph = rotate_cw(graph)
for line in graph:
    print("".join(line))

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


for i in range(h):
    tmp = input()
    for j in range(len(tmp)):
        graph[i][j] = tmp[j]
graph = np.array(graph)

flag = True
while flag:
    flag = False
    for i in range(graph.shape[1]):
        if( graph[:,i] == ['.']*graph.shape[0]).all():
            flag = True
            if i == 0:
                graph = graph[: , 1:]
                break
                
            if i == graph.shape[1] -1:
                graph = graph[:,:i]
                break
                
            else:
                graph = np.concatenate([graph[:,:i],graph[:,i+1:] ], 1)
                break
                
    for i in range(graph.shape[0]):
        if (graph[i,:] == ['.']*graph.shape[1]).all():
            flag = True
            if i == 0:
                graph = graph[1: , :]
                break
                
            if i == graph.shape[0] -1:
                graph = graph[:i,:]
                break
                
            else:
                graph = np.concatenate([graph[:i , :],graph[i+1: , :] ], 0)
                break
                
for i in graph:
    print(*i, sep="")

Solution (Python):
h, w = map(int, input().split())
a = [input() for i in range(h)]
w_row = []
w_column = []
for i in range(h):
  black = False
  for j in range(w):
    if a[i][j] == '
      black = True
      break
  if not black:
    w_row.append(i)
for i in range(w):
  black = False
  for j in range(h):
    if a[j][i] == '
      black = True
      break
  if not black:
    w_column.append(i)
for i in range(h):
  if i in w_row:
    continue
  s = ''
  for j in range(w):
    if j in w_column:
      continue
    s += a[i][j]
  print(s)

Solution (Python):
from collections import defaultdict
d = defaultdict(int)
H, W = map(int, input().split())
L = []
for i in range(H):
    L.append(input())
cl = L[:]

al = []
for i in cl:
    if ('
        al.append(i)

if (len(al) == 0):
    print()
    exit()

for i in range(W):
    d[i] = True

for i, v in enumerate(al):
    for k, j in enumerate(v):
        if (j == '.'):
            continue
        else:
            d[k] = False
for i, v in d.items():
    if (v):
        for j, k in enumerate(al):
            if (i == 0):
                al[j] = ' ' + k[1:]
            elif ((i == W - 1) and (W != 1)):
                al[j] = k[:i] + ' '
            else:
                al[j] = k[:i] + ' ' + k[i + 1:]
for i in al:
    print(i.replace(' ', ''))

Solution (Python):
h,w = map(int,input().split())
fi = [input() for _ in range(h)]
row = [False]*h
col = [False]*w
for i in range(h):
    for j in range(w):
        if fi[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(fi[i][j],end='')
        print()

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

ans=[[] for i in range(l)]
for i in range(w):
    for j in range(l):
        if a[j][i]=="
            for k in range(l):
                ans[k].append(a[k][i])
            break
for i in range(l):
    print("".join(ans[i]))

Solution (Python):
H, W = list(map(int,input().split()))
A = [list(input()) for _ in range(H)]
NA = []
for a in A:
    if '
        NA.append(a)
for i in range(W):
    ydel = True
    for j in NA:
        if j[i] == '
            ydel = False
            break
    if not ydel:
        continue
    for j in NA:
        j[i] = 'D'
for na in NA:
    nna = []
    for i in na:
        if i != 'D':
            nna.append(i)
    print(''.join(nna))

Solution (Python):
H, W = map(int, input().split())
print(*map(lambda l: "".join(l), zip(*[column for column in zip(*[row for row in [input() for _ in range(H)] if "

Solution (Python):
import numpy as np
H, W = map(int, input().split())
A = []
for _ in range(H):
    row = input()
    if row != "." * W:
        A.append(list(row))
A = np.array(A, dtype=str)
B = []
for c in range(W):
    if any(map(lambda c: c == "
        B.append(A[:, c])
for row in np.asarray(B).T:
    print("".join(row))

Solution (Python):
h,w = map(int,input().split())
map_input = [[1 if j=='

h_li = [0]*h
w_li = [0]*w

for i in range(h):
    for j in range(w):
        h_li[i]+=map_input[i][j]
        w_li[j]+=map_input[i][j]

for i in range(h):
    if h_li[i]==0:
        continue
    tmp=[]
    for j in range(w):
        if w_li[j]==0:
            continue
        tmp.append(map_input[i][j])
    print(''.join(['.' if k==0 else '

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

a=list(zip(*[i for i in a if "
a=list(zip(*[i for i in a if "

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

Solution (Python):
H, W = map(int, input().split())
a = list()
for _ in range(H):
    a.append(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 = list(map(int, input().split()))
ss = []
for _ in range(h):
    s = input().strip()
    if '
        ss.append(s)
new_h = len(ss)
dels = []
for i in range(w):
    rep = True
    for j in range(new_h):
        if ss[j][i] == '
            rep = False
    if rep:
        dels.append(i)
for i in range(new_h):
    now = ss[i]
    pri = []
    for j in range(w):
        if j not in dels:
            pri.append(now[j])
    print(''.join(pri))

Solution (Python):


import sys






















def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    h, w = mi()
    L = [li() for _ in range(h)]
    L_t = [col for col in zip(*L)]
    
    
    
    
    
    
    
    

    i_strip = set()
    j_strip = set()
    for i in range(h):
        if all(map(lambda x: x == '.', L[i])):
            i_strip.add(i)
    for j in range(w):
        if all(map(lambda x: x == '.', L_t[j])):
            j_strip.add(j)
    
    
    for i in range(h):
        if i not in i_strip:
            for j in range(w):
                if j not in j_strip:
                    print(L[i][j], end='')
            print('')


if __name__ == "__main__":
    main()

Solution (Python):
import sys
z = []
x = list(map(int, input().split()))
s = [list(input()) for i in range(x[0])]
h = x[0]
w = x[1]
l = []
y = []

for i in range(0, h):
  for j in range(0, w):
    if s[i][j] == '
      y.append(s[i])
      break

t = []


for j in range(0, len(y[0])):
  for i in range(0, len(y)):
    l.append(y[i][j])
  t.append(l)
  l = []

p = []
for i in range(0, len(t)):
  for j in range(0, len(t[i])):
    if t[i][j] == '
      p.append(t[i])
      break
u = []
for j in range(0, len(p[0])):
  for i in range(0, len(p)):
    l.append(p[i][j])
  u.append(l)
  l = []
for i in u:
  print(''.join(i))

Solution (Python):
h,w = map(int,input().split())
a = [input() for _ in range(h)]
skip_w = []
for i in range(w):
    cnt = 0
    for j in range(h):
        if a[j][i] == '.':
            cnt += 1
    if cnt == h:
        skip_w.append(i)
for i in range(h):
    if a[i] == '.'*w:
        continue
    else:
        for j in range(w):
            if j not in skip_w:
                print(a[i][j], end='')
        print()

Solution (Python):
h,w = map(int, input().split())
flg = 0
a = []
for i in range(h):
  s = input()
  if '
    a.append(s)
  else:
    flg += 1
h -= flg
res = ['']*h
for i in range(w):
  flg = 0
  for j in range(h):
    if a[j][i] == '
      flg = 1
  if flg == 1:
    for j in range(h):
      res[j] += a[j][i]
for i in range(h):
  print(res[i])

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

MAP = [list(input()) for i in range(H)]
check = ['.' for j in range(W)]
MAP_h = []
MAP_T = []

for i in range(H):
    if check != MAP[i]:
        MAP_h.append(MAP[i])
   
check = ['.' for k in range(len(MAP_h))]   

for i in range(W):
    tmp = [row[i] for row in MAP_h]
    if tmp != check:
        MAP_T.append(tmp)

MAP= map(list, zip(*MAP_T))

for l in MAP:
    print(''.join(l))

Solution (Python):
h, w = [int(x) for x in input().split()]
 
temp_list = []
flag = [False] * w
for _ in range(h):
    a = input()
    if "
        continue
    temp_list.append(a)
    for i in range(w):
        flag[i] = flag[i] or a[i] == "

for temp in temp_list:
    print("".join([temp[i] for i in range(w) if flag[i]]))

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 i in range(H)]
 
A = [x for x in A if "
A = list(zip(*A)) 
A = [x for x in A if "
A = list(zip(*A)) 
for x in A:
  print("".join(x))

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

f = []

for i in range(h):
    f.append(list(input()))
    
a = []
    
for i in range(len(f)):
    if f[i] == ["."]*len(f[i]):
        a.append(i)
        
for i in a:
    del f[i]
    for s in range(len(a)):
        a[s] -= 1
        
f2 = []

for i in range(w):
    s = []
    
    for k in f:
        s.append(k[i])
        
    f2.append(s)
    
b = []
    
for i in range(len(f2)):
    if f2[i] == ["."]*len(f2[i]):
        b.append(i)
        
for i in b:
    del f2[i]
    for s in range(len(b)):
        b[s] -= 1
        
ff = []

for i in range(len(f2[0])):
    s = []
    
    for k in f2:
        s.append(k[i])
        
    ff.append(s)
        
for i in ff:
    for s in range(len(i)-1):
        print(i[s],end = "")
    
    print(i[-1])

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

while True:
  ans = 0
  for h in range(H):
    if list(set(S[h]))[0] == ".":
      S.pop(h)
      H -= 1
      ans = 1
      
      
      break
  for w in range(W):
    
    if list(set([S[h][w] for h in range(H)]))[0] == ".":
      for h in range(H):
        S[h].pop(w)
      W -= 1
      ans = 1
      
      
      break
  if ans == 0:
    break

for h in range(H):
  print("".join(S[h]))

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

b_rows = []
for row in range(H):
    if field[row].count(".") != W:
        b_rows.append(row)

b_columns = []
for column in range(W):
    memo = []
    for row in range(H):
        memo.append(field[row][column])
    if memo.count(".") != H:
        b_columns.append(column)

for i in b_rows:
    for j in b_columns:
        print(field[i][j], end="")
    print()

Solution (Python):
H,W=map(int,input().split())
A=[list(input())for i in range(H)]
ww=set()
hh=set()
for h in range(H):
  for w in range(W):
    if A[h][w]=='
      ww.add(w)
      hh.add(h)
ww=sorted(list(ww))
for h in sorted(list(hh)):
  _=''
  for w in ww:
    _+=A[h][w]
  print(_)

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

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

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

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

Solution (Python):
H,W = map(int,input().split())
t = []
Hcut = []
Wcut = []
count = 0
for i in range(H):
  t.append(input())
  

for i in range(H):
  for j in range(W):
    if t[i][j] == "
      count += 1
      break
  if count == 0:
    Hcut.append(i)
  count = 0
  

for i in range(W):
  for j in range(H):
    if t[j][i] == "
      count += 1
      break
  if count == 0:
    Wcut.append(i)
  count = 0


for i in range(H):
  judge = 0
  for j in range(W):
    if i in Hcut or j in Wcut:
      continue
    else:
      print(t[i][j],end="")
      judge = 1
  if judge == 1:
    print()

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

emp_row = [False] * H
emp_col = [False] * W

for i in range(H):
  isEmp = True
  for j in range(W):
    if A[i][j] == "
      isEmp = False
      break
  emp_row[i] = isEmp
  
for i in range(W):
  isEmp = True
  for j in range(H):
    if A[j][i] == "
      isEmp = False
  emp_col[i] = isEmp
  
ANS = []
for i in range(H):
  if emp_row[i]:
    continue
  row = []
  for j in range(W):
    if emp_col[j]:
      continue
    row.append(A[i][j])
  ANS.append(row)
  
for a in ANS:
  print("".join(a))

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

for i in range(H):
  line = input()
  if line != '.' * W:
    G.append(line)

H = len(G)
ans = []

for i in range(W):
  flg = False
  tmp = ''
  for j in range(H):
    if G[j][i] == '.':
      flg = False
    else:
      flg = True
    tmp += G[j][i]
  if tmp != '.' * H:
    ans.append(tmp)

for i in range(H):
  tmp = ''
  for j in range(len(ans)):
    tmp += ans[j][i]
  print(tmp)

Solution (Python):
H, W = map(int, input().split())
X = []
res = []
F = [True] * W

for i in range(H):
  x = list(input())
   
  if x.count("
    X.append(x)

  for j in range(W):
    if x[j] == "
      F[j] = False

for k in range(len(X)):
  r = ""
  for l in range(W):
    if not F[l]:
      r += (X[k][l])
  print(r)

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

r=[]
c=[]

for i in range(h):
    if a[i].count('
        r.append(i)
for i in range(w):
    if at[i].count('
        c.append(i)

for i in range(len(r)):
    del a[r[i]-i]
for j in range(len(c)):
    for i in range(h-len(r)):
        del a[i][c[j]-j]

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

Solution (Python):
h,w = map(int, input().split())
ar = []
for _ in range(h):
  row = list(input())
  if row == ['.']*w:
    continue
  ar.append(row)

c = 0
while c < len(ar[0]):
  count = 0
  for r in range(len(ar)):
    if ar[r][c] == '
      count += 1
  if count == 0:
    for row in ar:
      row.pop(c)
  else:
    c += 1

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

Solution (Python):

import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi

H, W = ri_()
a = [[i for i in rs()] for _ in range(H)]
a = [i for i in a if i.count('
a = list(zip(*a))
a = [i for i in a if i.count('
a = list(zip(*a))
a = [''.join(i) for i in a]
for ai in a:
    print(ai)

Solution (Python):
import numpy as np

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

D = A[A == "."]

while True:

    B = A[np.any(A != ".", axis= 1)]
    B = B[:, np.any(A != ".", axis = 0)]

    if np.array_equal(A, B) == True:
        break
    else:
        A = B 

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

Solution (Python):
A,B=[],[]
h,w=map(int,input().split())
for i in range(h):
    a=input()
    if "
        A.append(a)
b=""
for i in range(w):
    if "
        B.append(i-1)
    b=""
    for j in range(len(A)):
        b+=A[j][i]
if "
    B.append(w-1)
B.pop(0)
o=0
for i in range(len(A)):
    o=0
    A[i]=list(A[i])
    for j in B:
        A[i].pop(j-o)
        if o==len(B)-1:
            print("".join(A[i]))
        o+=1
if len(B)==0:
    for i in A:
        print("".join(i))

Solution (Python):
h,w = map(int,input().split())
H = []
l = []
for i in range(h):
  k = list(input())
  if len(set(k)) == 1 and k[0] == '.':
    H.append(i)
  l.append(k)
W = []
for j in range(w):
  flag = True
  x = l[0][j]
  if x == '.':
    for k in l:
      if k[j] != x:
        flag = False
    if flag:
      W.append(j)
for i in H: 
  for j in range(w):
    l[i][j] = ''
for j in W:
  for i in range(h):
    l[i][j] = ''
for k in l:
  if ''.join(k) != '':
    print(''.join(k))

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] == True:
        for j in range(w):
            if col[j] == True:
                print(a[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] == True:
        for j in range(w):
            if col[j] == True:
                print(a[i][j],end = '')
        print()

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

for i in range(H):
    sharp_cnt = a[i].count("
    if sharp_cnt != 0:
        ans1.append(a[i])

slicer = []
for j in range(W):
    sharp_cnt = 0
    for i in range(len(ans1)):
        if ans1[i][j] == "
            sharp_cnt +=1
    if sharp_cnt == 0:
        slicer.append(j)

del_cnt = 0
for i in slicer:
    i = i - del_cnt
    for j in ans1:
        del j[i]
    del_cnt += 1

for i in ans1:
    print(*i, sep = "")

Solution (Python):

ans_index = []

def get_index(s):
    a = ""
    for ans in ans_index:
        a += s[ans]
    return a


def main():
    H, W = map(int, input().split())
    A = []
    for _ in range(H):
        s = input()
        if s != "." * W:
            A.append(s)

    for w in range(W):
        add = True
        for h in range(len(A)):
            if A[h][w] != ".":
                add = False
                break
        if not add:
            ans_index.append(w)

    

    for line in map(get_index, A):
        print("".join(line))
    return

if __name__ == '__main__':
    main()

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

tate,yoko = set(),set()
for i in range(H):
    t = True
    for j in range(W):
        if a[i][j] == "
            t = False
            break
    if t:
        tate.add(i)
for j in range(W):
    y = True
    for i in range(H):
        if a[i][j] == "
            y = False
            break
    if y:
        yoko.add(j)

ct = 0
for t in tate:
    a = a[:t-ct] + a[t+1-ct:]
    ct += 1

cy = 0
for y in yoko:
    for i in range(H-len(tate)):
        a[i] = a[i][:y-cy] + a[i][y+1-cy:]
    cy += 1

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

Solution (Python):
import sys

readline = sys.stdin.readline

def main():
    H, W = map(int, readline().split())
    grid = []
    for _ in range(H):
        A = list(readline()[:-1])
        if '
            grid.append(A)

    for i in range(W-1, -1, -1):
        flag = True
        for j in range(len(grid)):
            if grid[j][i] == '
                flag = False
                break
        if flag:
            for k in range(len(grid)):
                del grid[k][i]
    
    for k in range(len(grid)):
        print(''.join(grid[k]))


if __name__ == "__main__":
    main()

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

for s in S:
    if '
        continue
    T.append(s)

S = []
for t in list(zip(*T)):
    if '
        continue
    S.append(t)
    
for s in list(zip(*S)):
    print(''.join(map(str, s)))

Solution (Python):
h, w = map(int, input().split())
a = []
for i in range(h):
    s = input()
    if s.count('.') != w:
        a.append(s)
b = []
for i in range(w):
    f = True
    for x in a:
        if x[i] != '.':
            f = False
    if f:
        b.append(i)
for x in a:
    for i in range(len(x)):
        f = True
        for j in b:
            if i == j:
                f = False
        if f:
            print(x[i], end='')
    print()

Solution (Python):
H,W = map(int,input().split())
A = [list(input()) for _ in range(H)]
for h in range(H):
  if A[h].count('.') == W:
    for w in range(W):
      A[h][w] = ''
for h in range(H):
  for w in range(W):
    if A[h][w] == '.':
      for i in range(H):
        if A[i][w] == '
          break
        if i == H-1:
          for j in range(H):
            A[j][w] = ''

for i in range(H):
  if ''.join(A[i]) == '':
    continue
  print(''.join(A[i]))

Solution (Python):
h,w = map(int,input().split())
a = [input() for i in range(h)]
col = [0]*h
row = [0]*w
for i in range(h):
    for j in range(w):
        if a[i][j] == "
            col[i] = 1
            row[j] = 1
for i in range(h):
    ans=""
    for j in range(w):
        if col[i] == 1 and row[j] == 1:
            ans+=a[i][j]
    if ans!="":
        print(ans)

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


def read():
    H, W = map(int, input().strip().split())
    A = []
    for i in range(H):
        a = list(input().strip())
        A.append(a)
    return H, W, A


def solve(H, W, A):
    is_skip_rows = [True for i in range(H)]
    is_skip_cols = [True for j in range(W)]
    for i in range(H):
        for j in range(W):
            if A[i][j] == '
                is_skip_rows[i] = False
                is_skip_cols[j] = False
    for i in range(H):
        if is_skip_rows[i]:
            continue
        line = []
        for j in range(W):
            if is_skip_cols[j]:
                continue
            line.append(A[i][j])
        print(''.join(line))


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Solution (Python):
import numpy as np
h,w = map(int,input().split())
s = []
for i in range(h):
    tmp = list(input())
    if len(set(tmp)) == 1 and tmp[0] == '.':
        continue
    s.append(tmp)
ss = np.array(s).T
ans1 = []
si = ss.tolist()

for i, w in enumerate(si):
    if len(set(w)) == 1 and w[0] == '.':
        continue
    else:
        ans1.append(w)
ans = np.array(ans1).T.tolist()

for i, w in enumerate(ans):
    print(''.join(w))

Solution (Python):
h,w = map(int,input().split())
a = [[i == "
line,row = [0]*w,[0]*h
for i in range(h):
  for j in range(w):
    if a[i][j]:
      line[j] = 1
      row[i] = 1
for i in range(h):
  if not row[i]:
    continue
  ans = ""
  for j in range(w):
    if line[j]:
      ans += "
  print(ans)

Solution (Python):
h,w=map(int,input().split())
s=[]
for i in range(h):
  t=input()
  if t.count('.')!=len(t):
    s.append(t)

l=[list(x) for x in zip(*s)]
t2=[]
for e in l:
  if e.count('.')!=len(e):
    t2.append(e)

ans=[list(x) for x in zip(*t2)]
for e in ans:
  print(''.join(e))

Solution (Python):
h,w = map(int, input().split())
A = []
for i in range(h):
    s = input()
    
    if not s == '.'*w:
        A.append([j for j in s])
if len(A) > 1:
    for j in range(len(A[0])-1,-1,-1):
        
        c = 0
        for i in range(len(A)-1,-1,-1):
            
            if A[i][j] == '.':
                
                c +=1
        if c == len(A):
            for k in range(len(A)-1,-1,-1):
                A[k].pop(j)
else:
    for l in range(len(A[0])-1,-1,-1):

        if A[0][l] == '.':
            A[0].pop(l)

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

Solution (Python):
import numpy as np
H, W = map(int, input().split())
grid = []
for _ in range(H):
    a = [i for i in input()]
    if "
        grid.append(a)
grid = np.array(grid)
grid_T = grid.T
ans = []
for i in range(W):
    if "
        ans.append(grid_T[i])
ans = np.array(ans).T
for i in range(ans.shape[0]):
    print("".join(ans[i]))

Solution (Python):
import numpy as np

def ABC107B(h, w, a):
    b = np.zeros((h, w), dtype=str)
    for i in range(h):
        b[i, :] = np.array(list(a[i]))
    H = []
    W = []
    for i in range(h):
        if any(b[i, :] == '
            H.append(i)
    for j in range(w):
        if any(b[:, j] == '
            W.append(j)
    lenH = len(H)
    lenW = len(W)
    for i in range(h):
        if H.count(i) == 1:
            string = ''
            for j in range(w):
                if W.count(j) == 1:
                    string = string + b[i, j]
            print(string)

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

Solution (Python):
import numpy as np
h,w=map(int,input().split())
a=np.array([ list(input()) for i in range(h)])
count=0
d_w=[]
d_h=[]
for i in range(0,h):
  count=0
  for j in range(0,w):
    if a[i][j]==".":
      count+=1
  if count==w:
    d_w.append(i)
for i in range(0,w):
  count=0
  for j in range(0,h):
    if a[j][i]==".":
      count+=1
  if count==h:
    d_h.append(i)
a=np.delete(a,d_w,0)
a=np.delete(a,d_h,1)
for i in a:
  print("".join(i))

Solution (Python):
h, w = map(int, input().split())
mat = []
idx = []
mat2 = []
for i in range(h):
    tmp = input()
    if tmp.count('.') != w:
        mat.append(tmp)


for i in range(w):
    tmp2 = ''
    for j in range(len(mat)):
        tmp2 += mat[j][i]
    mat2.append(tmp2)

mat.clear()
for i in range(len(mat2)):
    if mat2[i].count('.') != len(mat2[i]):
        mat.append(mat2[i])

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

Solution (Python):
import numpy as np
def main():
    H,W = map(int,input().split())
    grid = np.array([list(input()) for _ in range(H)],str)
    grid = grid[:,np.any(grid == '
    grid = grid[np.any(grid == '
    print('\n'.join(''.join(row) for row in grid))
if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
from copy import deepcopy
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

h,w=MI()
data=[list(input().rstrip()) for i in range(h)]

deletes=[]
for i in range(h):
    count=0
    for j in range(w):
        if data[i][j]==".":
            count+=1
    if count==w:
        deletes.append(i)
for j in list(reversed(deletes)):
    del data[j]

h-=len(deletes)
data2=[[0 for i in range(h)] for j in range(w) ]
for i in range(w):
    for j in range(h):
        data2[i][j]=data[j][i]

deletes2=[]
for i in range(w):
    count=0
    for j in range(h):
        if data2[i][j]==".":
            count+=1
    if count==h:
        deletes2.append(i)
for j in list(reversed(deletes2)):
    del data2[j]
w-=len(deletes2)

data3=[[0 for i in range(w)] for j in range(h)]


for i in range(h):
    for j in range(w):
        data3[i][j]=data2[j][i]

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