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):
def examA():
    N, i = LI()
    ans = N - i + 1
    print(ans)
    return

def examB():
    H, W = LI()
    A = [SI() for _ in range(H)]
    h = [[]for _ in range(H)]
    for i in range(W):
        flag = False
        for j in range(H):
            if A[j][i]=="
                flag = True
                break
        if flag:
            for j in range(H):
                h[j].append(A[j][i])
    
    ans = []
    for i,a in enumerate(h):
        if "
            ans.append(i)
    for v in ans:
        print("".join(map(str,h[v])))
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examB()

"""

"""

Solution (Python):
h, w = map(int, input().split())
l = []
for i in range(h):
  a = str(input())
  if a == '.'*w:
    continue
  l.append(a)

skip = []
for i in range(w):
  for j in range(len(l)):
    if l[j][i] == '
      break
  else:
    skip.append(i)

skip = set(skip)
l_ = [0]*len(l)
for i in range(len(l)):
  temp = ''
  for j in range(w):
    if j not in skip:
      temp += l[i][j]
  l_[i] = temp
  
for i in range(len(l_)):
  print(l_[i])

Solution (Python):
h, w = map(int, input().split())
l = []
for i in range(h):
  a = str(input())
  if a == '.'*w:
    continue
  l.append(a)

skip = []
for i in range(w):
  for j in range(len(l)):
    if l[j][i] == '
      break
  else:
    skip.append(i)

skip = set(skip)
l_ = [0]*len(l)
for i in range(len(l)):
  temp = ''
  for j in range(w):
    if j not in skip:
      temp += l[i][j]
  l_[i] = temp
  
for i in range(len(l_)):
  print(l_[i])

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

for i in range(h):
  tmp = input()
  if tmp != '.'*w:
    ban.append(list(tmp))

for zlist in zip(*ban):
  if '
    banban.append(zlist)

for letter in zip(*banban):
  print(''.join(letter))

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


def read_list():
    return list(read_values())


def main():
    H, W = read_values()
    F = [input() for _ in range(H)]

    T = [False] * W
    for f in F:
        if f.count("
            continue
        
        for w, s in enumerate(f):
            if s == "
                T[w] = True

    for f in F:
        if f.count("
            continue
        print("".join([s for i, s in enumerate(f) if T[i]]))


if __name__ == "__main__":
    main()

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

r = [False]*h
c = [False]*w
for i in range(h):
    for j in range(w):
        if A[i][j] == '
            r[i] = True
            c[j] = True

for i in range(h):
    if r[i]:
        for j in range(w):
            if c[j]:
                print(A[i][j], end='')
        print()

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

for p in range(w):
    f=True
    for q in range(h):
        if a[q][p]=="
    if f:
        for y in range(h):a[y][p]=""
res=[]
for t in a:
    if t.count(".")+t.count("")!=len(t):res.append(t)
for t in res:
    print("".join(t))

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


def main():
    H, W = map(int, input().split())
    
    A = np.array([list(input()) for _ in range(H)])
    A = A[:, ~np.all(A == '.', axis=0)]
    A = A[~np.all(A == '.', axis=1), :]
    [print(''.join(A[i, :])) for i in range(np.shape(A)[0])]


if __name__ == "__main__":
    main()

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

Solution (Python):
h,w = map(int, input().split())
a = []
yoko = [False]*h
tate = [False]*w
for i in range(h):
    a.append(list(str(input())))

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

for x in range(h):
    if yoko[x]:
        for y in range(w):
            if tate[y]:
                print(a[x][y], end="")
        else:
            print("")

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

V=[0]*H
X=[0]*W
for i in range (H):
	for j in range (W):
		if A[i][j]=="
			V[i]=1
			X[j]=1

for i in range (H):
	if V[i]==1:
		for j in range (W):
			if X[j]==1:
				print(A[i][j],end="")
		print()

Solution (Python):
h,w=map(int,input().split())
a=[[j for j in input()] for i 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):
import numpy as np
H, W = map(int, input().split())
a = np.array([list(input()) for _ in range(H)])


del_index_0 = []
for i in range(H):
    if np.all(a[i]==['.']*W):
        del_index_0.append(i)
b = np.delete(a, del_index_0, axis=0)


del_index_1 = []
for i in range(W):
    if np.all(b[:,i]==['.']*(H-len(del_index_0))):
        del_index_1.append(i)
c = np.delete(b, del_index_1, axis=1)

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

Solution (Python):
h,w=map(int,input().split())
slist=[input() for i in range(h)]
c=1
while c==1:
  c=0
  for i in range(h):
    s=slist[i]
    if "
      del slist[i]
      h -= 1
      c=1
      break
  if c==0:
    for i in range(w):
      li = [slist[j][i] for j in range(h)]
      if len(set(li))==1 and "." in li:
        for j in range(h):
          slist[j]=slist[j][:i]+slist[j][i+1:]
        c=1
        w -=1
        break
for i in range(h):
  print(slist[i])

Solution (Python):
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'

    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()

input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a
 
show_flg=False
show_flg=True
 
ans=0

h,w=LI()
t=[]
for i in range(h):
    s=input()
    if s=='.'*w:
        continue
    t+=[s]

u=[[0]*len(t) for i in range(w)]
for i in range(len(t)):
    for j in range(w):
        u[j][i]=t[i][j]

ans=[]
for x in u:
    if x.count('
        0
    else:
        ans+=[x]

ANS=[[0]*len(ans) for i in range(len(ans[0]))]
for i in range(len(ans)):
    for j in range(len(ans[0])):
        ANS[j][i]=ans[i][j]
for i in ANS:
    print(''.join(i))

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

ku=[]
for i in range(w):
  for j in m:
    if j[i] == "
      break
  else:
    ku.append(i)

k = list(set([i for i in range(w)]) - set(ku))
for i in m:
  temp=""
  for j in k:
    temp += i[j]
  print(temp)

Solution (Python):
H,W=map(int,input().split())
A = []
hh = H
for y in range(H):
  ain = input()
  if "
    A.append(ain)
  else:
    hh -= 1
d = [ 0 for _ in range(W)]
for x in range(W):
  for y in range(hh):
    if A[y][x] == "
      break
  else:
    d[x] = 1
for y in range(hh):
  for x in range(W):
    if d[x] == 0:
        print(A[y][x], end="")
  print("")

Solution (Python):
def main():
    H, W = map(int, input().split(" "))
    grids = []
    for _ in range(H):
        line = input()
        if "
            grids.append([l for l in line])
        else:
            continue
    for i in range(W):
        tmp = 0
        for grid in grids:
            if grid[i] == ".":
                tmp += 1
        if tmp == len(grids):
            for grid in grids:
                grid[i] = ""
    for grid in grids:
        print("".join(grid))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
H_W = list(map(int,input().split()))
H = H_W[0]
W = H_W[1]
b = [[0 for i in range(W)] for j in range(H)]
a = [[str(c) for c in l.strip()] for l in sys.stdin]


for i in range(H):
    for j in range(W):
        if a[i][j] == '
            b[i][j] = 1


w = [0] * W
h = [0] * H
for i in range(H):
    for j in range(W):
        h[i] = h[i] + b[i][j]
        w[j] = w[j] + b[i][j]




i = 0
c = 0
j = 0
for i in range(H):
    if h[i] == 0:
        del a[j]
        H = H - 1
        j = j - 1
    j = j + 1


k = 0
for i in range(W):
    if w[i] == 0:
        for j in range(H):
            del a[j][k]
        W = W - 1
        k = k - 1
    k = k + 1


for i in range(H):
    flag = 0
    for j in range(W):
        if flag == 0:
            ans = a[i][j]
            flag = 1
        else:
            ans = ans + a[i][j]
    print(ans)

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())
l=[list(input()) for _ in range(h)]
l=[x for x in l if '
l=[x for x in zip(*l) if '
for i in zip(*l):
	print(''.join(i))

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

for i in range(H):
    a[i]=input()
    
ans=[[0]*W for _ in range(H)]

for i in range(H):
    if a[i]=="."*W:
        continue
    else:
        for j in range(W):
            if a[i][j]==".":
                ans[i][j]=1
            else:
                ans[i][j]=2

        
        
for j in range(W):
    if 2 in [row[j] for row in ans]:
        continue
    else:
        for i in range(H):
            ans[i][j]=0
        
for i in range(H):
    temp=""
    for j in range(W):
        if ans[i][j]==1:
            temp+="."
        elif ans[i][j]==2:
            temp+="
    if temp!="":
        print(temp)

Solution (Python):
def initSquare(H, W):
    square = []
    for r in range(H):
        row = []
        row_string = input()
        for letter in row_string:
            row.append(letter)
        square.append(row)
    return square

def rowChecker(square):
    delete_row_indexes = []
    for i, row in enumerate(square):
        if "
            delete_row_indexes.append(i)            
    return delete_row_indexes

def columnChecker(square):
    delete_column_indexes = []
    for c in range(W):
        column = []
        for r in range(H):
            column.append(square[r][c])
        if "
            delete_column_indexes.append(c)            
    return delete_column_indexes

def generateNewSquare(square, delete_row_indexes,delete_column_indexes):
    new_square = []
    for r, row in enumerate(square):
        if r not in delete_row_indexes:
            new_row = []
            for c, column in enumerate(row):
                if c not in delete_column_indexes:
                    new_row.append(column)
            new_square.append(new_row)
    return new_square

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

square = initSquare(H, W)
delete_row_indexes = rowChecker(square)
delete_column_indexes = columnChecker(square)
new_square = generateNewSquare(square, delete_row_indexes,delete_column_indexes)

for row in new_square:
    row_string = ''.join(row)
    print(row_string)

Solution (Python):

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

grid = []
cols = [True for _ in range(W)]
rows = [True for _ in range(H)]

for _ in range(H):
    tmp = input()
    grid.append(tmp);
    
for i in range(H):
    if grid[i].count('.') == W:
        rows[i] = False        


for i in range(W):
    count = 0
    for j in range(H):
        if grid[j][i] == '.':
            count += 1
    if count == H:
        cols[i] = False

for i in range(H):
    if rows[i]:
        for j in range(W):
            if cols[j]:
                print(grid[i][j], end="")
        print()

Solution (Python):
H,W = map(int,input().split())
 
h = []
w_tmp = [0 for i in range(W)]
A =[]
for i in range(H):
  a = input()
  A.append(a)
  if "
    h.append(i)
  for j in range(W):
    if a[j] == "
      w_tmp[j]+=1
w =[]
for j in range(W):
  if w_tmp[j] > 0:
    w.append(j)
for i in h:
  for j in w:
    print(A[i][j],end="")
  print("")

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

grid = [list(input()) for _ in range(H)]
l = [x for x in grid if "
l = [x for x in zip(*l) if "

for i in zip(*l):
    print("".join(i))

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

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

g2 = []
for line in g:
    if '
        g2.append(line)

g3 = []
for _ in g2: g3.append([])

for j in range(w):
    if any([g2[i][j] == '
        for i in range(len(g3)):
            g3[i].append(g2[i][j])

for line in g3:
    print(''.join(line))

Solution (Python):
h,w=map(int,input().split())
a=[[j for j in input()] for i 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())
L=[list(input()) for _ in range(H)]
for _ in range(H+W):
    ans=[]
    res=[]
    l=[]
    for s in L:
        if '
            l.append(s)
    for z in zip(*l):
        if '
            res.append(z)
    for z in zip(*res):
        ans.append(list(z))
    L=ans.copy()
for t in L:
  print(''.join(t))

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

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

squares=[]

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


    
for i in range(H-1,-1,-1):
    if '
        del squares[i]
        

check_col =[]  
    
for j in range(W):
    flag=True
    for i in range(len(squares)):
        if squares[i][j] == '
            flag = False
    if flag:
        check_col.append(j)

check_col.sort(reverse=True)

for j in check_col:
    for i in range(len(squares)):
        del squares[i][j]
        


for i in range(len(squares)):
    print(''.join(squares[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):

import numpy as np

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

a = [list(str(input())) for i in range(H)]
b = []

for i in range(H):
    for j in range(W):
        if a[i][j]!=".":
            b.append(a[i])
            break

del_targets = []
b_arr = np.array(b)


            
for j in range(W):
    
    if b_arr[:,j].tolist().count(".") == len(b_arr[:,j].tolist()):
        del_targets.append(j)
        
ans = np.delete(b_arr, del_targets, 1)

for i in range(len(ans)):
    print(str(''.join(ans[i,:])))

Solution (Python):


h,w = map(int, input().split())
l = [list(list(input())) for i in range(h)]
W = []
for j in range(w):
    for k in range(h-1):
        if l[k][j] == l[k+1][j] == '.':
            continue
        else:
            break
    else:
        W.append(j)
W = sorted(W, reverse=True) 

H = []
for m in range(h):
    if set(l[m]) == {'.'}:
        H.append(m)
H = sorted(H, reverse=True) 

if l == [['
    print('
else:
    for p in range(len(W)):
        for q in range(h):
            del l[q][W[p]]
    
    for r in H:
        del l[r]
    
    for s in l:
        print(''.join(s))

Solution (Python):
h,w = map(int, input().split())
l = [list(list(input())) for i in range(h)]
W = []
for j in range(w):
    for k in range(h-1):
        if l[k][j] == l[k+1][j] == '.':
            continue
        else:
            break
    else:
        W.append(j)
W = sorted(W, reverse=True)


H = []
for m in range(h):
    if set(l[m]) == {'.'}:
        H.append(m)
H = sorted(H, reverse=True)


if l == [['
    print('
else:
    for p in range(len(W)):
        for q in range(h):
            del l[q][W[p]]
    
    
    for r in H:
        del l[r]
    
    
    for s in l:
        print(''.join(s))

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

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

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

Solution (Python):
h,w=map(int,input().split())
s = []
wl = [0]*w
hl = [0]*h
for _ in range(h):
  s.append(input())
for i in range(h):
  if s[i].count("
    hl[i] = 1
for j in range(w):
  cnt = 0
  for i in range(h):
    if s[i][j] == "
      break
    cnt += 1
  if cnt == h:
    wl[j] = 1
ans=[]
for i in range(h):
  tmp =""
  if hl[i] == 0:
    for j in range(w):
      if wl[j] == 0:
        tmp += s[i][j]
    ans.append(tmp)
for x in ans:
  print(x)

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

for i in range(h):
    line = input()
    for j in range(w):
        a[i][j] = line[j]

delete_row = []
for i in range(h):
    chk = True
    for j in range(w):
        if a[i][j] == '
            chk = False
            break
    if chk:
        delete_row.append(i)

for row in delete_row[::-1]:
    a.pop(row)

delete_col = []
for i in range(w):
    chk = True
    for j in range(h-len(delete_row)):
        if a[j][i] == '
            chk = False
            break
    if chk:
        delete_col.append(i)

for row in a:
    for col in delete_col[::-1]:
        row.pop(col)

for i in a:
    for j in i:
        print(j, end='')
    print()

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

a = [list(input()) for _ in range(H)]

h = [False]*H
w = [False]*W

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

Solution (Python):
import numpy as np

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

b=[]
c=[]
count1=0
count2=0

for i in range(H):
    l=a[i]
    
    if not((len(set(l))==1)and(l[0]==".")):
        b.append(l)
        count1=count1+1
b=np.array(b)
b=b.T
b=b.tolist()

for i in range(W):
    l=b[i]
    
    if not((len(set(l))==1)and(l[0]==".")):
        c.append(l)
        count2=count2+1

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

for i in c:print(*i,sep='')

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

ll = [list(input()) for _ in range(h)]
lh = [h for h in ll if '
lw = zip(*[w for w in zip(*lh) if '

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

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

ll = [list(input()) for _ in range(h)]
ll = [s for s in ll if '

lr = []
for i in range(w):
  if any(l[i] == '
    lr.append(i)

for l in ll:
  ans = ''
  for i in lr:
    ans += l[i]
  print(ans)

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

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

lr = []
for i in range(w):
  if any(l[i] == '
    lr.append(i)

for l in ll:
  ans = ''
  for i in lr:
    ans += l[i]
  print(ans)

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

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

lr = []
for i in range(w):
  if all(l[i] == '.' for l in ll):
    lr.insert(0, i)

for l in ll:
  for i in lr:
    l.pop(i)
  print(''.join(l))

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

h_check = [0] * H
w_check = [0] * W

for i in range(H):
  for j in range(W):
    if A[i][j] == ".":
      h_check[i] += 1
      w_check[j] += 1

h_check = list(map(lambda x: 1 - x // W, h_check))
w_check = list(map(lambda x: 1 - x // H, w_check))

for i in range(H):
  if h_check[i]:
    tmp = ""
    for j in range(W):
      if w_check[j]:
        tmp += A[i][j]
    print(tmp)

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

h_check = [0] * H
w_check = [0] * W

for i in range(H):
  flag = 0
  for j in range(W):
    if A[i][j] != ".":
      flag = 1
      break
  h_check[i] = flag

for j in range(W):
  flag = 0
  for i in range(H):
    if A[i][j] != ".":
      flag = 1
      break
  w_check[j] = flag

for i in range(H):
  if h_check[i]:
    tmp = ""
    for j in range(W):
      if w_check[j]:
        tmp += A[i][j]
    print(tmp)

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

h_check = [0] * H
w_check = [0] * W

for i in range(H):
  flag = 0
  for j in range(W):
    if A[i][j] != ".":
      flag = 1
      break
  h_check[i] = flag

for j in range(W):
  flag = 0
  for i in range(H):
    if A[i][j] != ".":
      flag = 1
      break
  w_check[j] = flag

for i in range(H):
  if h_check[i]:
    tmp = ""
    for j in range(W):
      if w_check[j]:
        tmp += A[i][j]
    print(tmp)

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

black_h = []
black_w = []

a = []
for h in range(H):
  s = input()
  for si, sv in enumerate(list(s)):
    if sv == '
      black_h.append(h)
      black_w.append(si)
  a.append(list(s))

ans = []
for h in range(H):
  if h not in black_h:
    continue
  A = []
  for w in range(W):
    if w not in black_w:
      continue
    A.append(a[h][w])
  ans.append(A)
  
for v in ans:
  print(''.join(v))

Solution (Python):

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
h,w = map(int,input().split())
a = []
for i in range(h):
    a.append(input())
row = []
col = []
for i in range(h):
    if a[i] == "."*w: row.append(i)
for j in range(w):
    flag = 0
    for i in range(h):
        if a[i][j] != ".": flag = 1
    if flag == 0:
        col.append(j)

for i in range(h):
    flag = 0
    if i in row:
        
        flag = 1
    if flag == 0:
        for j in range(w):
            if j not in col: print(a[i][j],end="")
        print("")

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 = []
dlrow = []
dlcol = []

efrow = list(range(h))
efcol = list(range(w))


for i in range(h):
    a.append(input())


for i in range(h):
    flg = True
    for j in range(w):
        if a[i][j] == '
            flg = False
    
    if flg == True:
        dlrow.append(i)
        efrow.remove(i)





for j in range(w):
    flg = True
    for i in range(h):
        if a[i][j] == '
            flg = False
    
    if flg == True:
        dlcol.append(j)
        efcol.remove(j)





for i in efrow:
    s = []
    s2 = []
    for j in efcol:
      s.append(a[i][j])
      s2 = "".join(s)
    print(s2)

Solution (Python):
H, W = map(int, input().split())
vax = []
hax = []
a = [str(input()) for i in range(H)]
for i in range(H):
    for j in range(W):
        if a[i][j] == '
            if i not in vax:
                vax.append(i)
            if j not in hax:
                hax.append(j)
vax.sort()
hax.sort()       
for i in vax:
    for j in hax:
        b = a[i][j]
        print(b,end="")
    print("")

Solution (Python):
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    H,W=map(int,input().split())
    A=[]
    for i in range(H):
        a=input()
        if a!='.'*W:
            A.append(a)
    ans=[[] for _ in range(len(A))]
    for i in range(W):
        f=False
        for j in range(len(A)):
            if A[j][i]=='
                f=True
                break
        if f:
            for j in range(len(A)):
                ans[j]+=A[j][i]
    for x in ans:
        print(''.join(x))

if __name__ == '__main__':
    main()

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

i = 0
while len(HW) > i:
  if "
    HW.pop(i)
    i -= 1
  i += 1  
  

clear_w = [0] * W
for i in range(len(HW)):
  for j in range(W):
    x = HW[i][j]
    if x == "
      clear_w[j] = 1

 
for i in range(len(HW)):
  HW[i] = [HW[i][j] for j in range(W) if clear_w[j] == 1]
  

for i in range(len(HW)):
  for j in range(len(HW[i])):
    if j != len(HW[i]) - 1:
      print(HW[i][j], end = "")
    else:
      print(HW[i][j])

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

    whitecolumn_index=row.find('.',0)
    whitecolumn=[]
    while(whitecolumn_index != -1):
        whitecolumn.append(whitecolumn_index)
        whitecolumn_index = row.find('.',whitecolumn_index+1)

    allwhite_column = list(set(allwhite_column) & set(whitecolumn))

    if(list(row).count('.')==w):
        allwhite_row.append(i)

    a.append(row)

for i in range(h):
    if(i not in allwhite_row):
        ans_i=[]
        for j in range(w):
            if(j not in allwhite_column):
                ans_i.append(a[i][j])
        print(''.join(ans_i))

Solution (Python):
n, m = map(int, input().split())
arr = list(list(input()) for _ in range(n))
rmv_row = [1] * n
rmv_col = [1] * m
for i in range(n):
    for j in range(m):
        if arr[i][j] == '
            rmv_row[i] = 0
            rmv_col[j] = 0
for i in range(n):
    if rmv_row[i] == 1:
        continue
    for j in range(m):
        if rmv_col[j] == 1:
            continue
        print(arr[i][j], end='')
    print()

Solution (Python):

import numpy as np

H, W = map(int, input().split())
c = 0
b = []
for i in range(H):
    a = list(input())
    if a != ["." for _ in range(W)]:
        b.append(a)
    else:
        c += 1

b = np.array(b)
b_T = b.T

B = []
for i in range(W):
    if list(b_T[i]) != ["." for _ in range(H-c)]:
        B.append(b_T[i])
B = np.array(B)
ans = B.T
for i in range(len(ans)):
    print("".join(map(str, ans[i])))

Solution (Python):
H, W = map(int, input().split())
allwhite = [True]*W
M = []
for _ in range(H):
    s = input()
    if s.count('.')==W: continue
    M.append(s)
    for w,c in enumerate(s):
        allwhite[w] *= c=='.'
    

for s in M:
    for c,f in zip(s, allwhite):
        if not f: print(c, end='')
    print()

Solution (Python):
h,w=map(int,input().split())
a=[[j for j in input()] for i 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=[]
for i in range(h):
  tmp=input()
  if len(tmp)!=tmp.count('.'):
    a.append(tmp)
  else:
    h-=1

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

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

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


deleterow = []
deleteline = []
for i in range(field.shape[0]):
    if set(field[i,:])=={'.'}:
        deleterow.append(i)
for j in range(field.shape[1]):
    if set(field[:,j])=={'.'}:
        deleteline.append(j)

for i, row in enumerate(field):
    if i in deleterow:
        continue
    for j, val in enumerate(row):
        if j in deleteline:
            continue
        print(val, end='')
    print('')

Solution (Python):
H, W = [int(i) for i in input().split()]
maze = [list(input()) for _ in range(H)]
maze = [l for l in maze if "
maze = list(zip(*maze))
maze = [l for l in maze if "
maze = list(zip(*maze))
maze = ["".join(l) for l in maze]
print(*maze, sep="\n")