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 = [""] * H
for i in range(H):
  A[i] = input()
  
row = [False] * H
col = [False] * W

for j in range(H):
  for k in range(W):
    if A[j][k] == "
      row[j] = True
      col[k] = True
      
for l in range(H):
  if row[l]:
    for m in range(W):
      if col[m]:
        print(A[l][m], end = "")
    print()

Solution (Python):
H, W = map(int, input().split())
a = [input() for _ in range(H)]
for i in range(H):
  if a[i] != "." * W:
    s = ""
    for j in range(W):
      if [X[j] for X in a].count("
        s += a[i][j]
    print(s)

Solution (Python):
H, W = map(int,input().split())
A = [input() for i in range(H)]
row = [False]*H
col = [False]*W
for i in range(H):
    for j in range(W):
        if A[i][j] == '
            row[i] = True
            col[j] = True
for i in range(H):
    if row[i]:
        for j in range(W):
            if col[j]:
                print(A[i][j], end = '')
        print()

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

Solution (Python):
H, W = map(int,input().split())
A = [input() for i in range(H)]
i = 0
for a in range(H):
    if '
        del A[i]
        H -= 1
        i -= 1
    i += 1

i = 0
for a in range(W):
    f = True
    for j in range(H):
        if A[j][i] == '
            f = False
            break
    if f:
        for j in range(H):
            A[j] = A[j][:i] + A[j][i+1:]
        W -= 1
        i -= 1
    i += 1
for a in A:
    print(a)

Solution (Python):
h,w=map(int,input().split())
a=[list(input()) for _ in range(h)]
ans=[i for i in a if '
s=[]
for i in range(w):
	t=0
	for j in a:
		t+=(j[i]=='
	if t==0:
		s+=[i]
for i in s[::-1]:
	for j in ans:
		del j[i]
for i in ans:
	print(''.join(i))

Solution (Python):

h, w = [int(i) for i in input().split()]
grid = []

for _ in range(h):
    line = list(input())
    if "
        grid.append(line)

ans = [[] for _ in range(len(grid))]

for i in range(w):
    for j in range(len(grid)):
        if grid[j][i] == "
            break
    else:
        continue
    for k in range(len(grid)):
        ans[k].append(grid[k][i])

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

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

for i in range(H):
    if '
        check.append(i-len(check))
for i in check:
    grid = grid[:i] + grid[i+1:]
check = []

for i in range(W):
    if all(grid[j][0][i]=='.' for j in range(len(grid))):
        check.append(i - len(check))
for i in check:
    for k in range(len(grid)):
        grid[k][0] = grid[k][0][:i] + grid[k][0][i+1:]
        
for i in grid:
    print(i[0])

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

for i in range(H):
    if '
        check.append(i-len(check))
for i in check:
    grid = grid[:i] + grid[i+1:]
check = []

for i in range(W):
    if all(grid[j][0][i]=='.' for j in range(len(grid))):
        check.append(i - len(check))
for i in check:
    for k in range(len(grid)):
        grid[k][0] = grid[k][0][:i] + grid[k][0][i+1:]
        
for i in grid:
    print(i[0])

Solution (Python):
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    H,W =map(int,input().split())
    A =[]
    h = []
    w = []
    count =0
    for i in range(H):
        a = list(str(input()))
        if a.count('
            continue
        else:
            A.append(a)
            count +=1


    for j in range(W):
        for i in range(count):
            if A[i][j] =="
                break

            if i == count-1:
                w.append(j)

    for i in range(count):
        for j in range(W):
            if j not in w:
                print(A[i][j],sep="",end="")
        print("")







if __name__ == "__main__":
    main()

Solution (Python):
H,W=map(int,input().split())
G=[list(input()) for i in range(H)]
allwhite=['.']*W
tmp=[]
for i in range(H):
    if G[i]!=allwhite:
        tmp.append(G[i])
G=tmp
ans=["" for i in range(len(G))]
for j in range(W):
    p=False
    for i in range(len(G)):
        if G[i][j]=='
            p=True
            break
    if p:
        for i in range(len(G)):
            ans[i]+=G[i][j]
print(*ans,sep='\n')

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

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

Solution (Python):
h,w =  map(int,input().split())
mat = [input() for i in range(h)]
n = 0
max = h
while n<max:
    if mat[n]=="."*w:
        mat.pop(n)
        n -= 1
        max -= 1
    n += 1
flag = [True for i in range(w)]
for i in mat:
    for j in range(w):
        if i[j]=="
            flag[j] = False
ans = []
for i in mat:
    temp = ""
    for j in range(w):
        if not flag[j]:
            temp += i[j]
    ans.append(temp)
for i in ans:
    print(i)

Solution (Python):
H, W = map(int, input().split())
A = []
for _ in range(H):
    a = input()
    if "
        A.append(a)
A_ = ["" for _ in range(len(A))]
for x in range(W):
    f = False
    for a in A:
        if a[x] == "
            f = True
            break
    if f:
        for y, a in enumerate(A):
            A_[y] += a[x]
for a in A_:
    print(a)

Solution (Python):

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

i = 0
while i < len(a):
    if all(m == '.' for m in a[i]) :
        a.pop(i)
    else:
        i += 1

H_sc = len(a)
w = 0
while w < len(a[0]):
    cnt = 0
    for h in range(H_sc):
        if a[h][w] == '
            w += 1
            break
        else:
            cnt += 1
    if cnt == H_sc:
        for b in a:
            b.pop(w)
for g in a:
    print(''.join(g))

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

Solution (Python):
a = input().split()
H = int(a[0])
W = int(a[1])
adj = int(0)
s = []
p = []

for k in range(H):
    m = input()
    for i in range(W):
        p.append(m[i])
    s.append(p)
    p = []

for i in range(W):
    i = i - adj
    temp = int(0)
    for k in range(H):
        if s[k][i] == "
            temp = 1
            break
        else:
            pass
    if temp == 0:
        for k in range(H):
            del s[k][i]
        adj += 1
    else:
        pass

W = W - adj
adj = 0

for i in range(H):
    i = i - adj
    temp = int(0)
    for k in range(W):
        if s[i][k] == "
            temp = 1
            break
        else:
            pass
    if temp == 0:
        del s[i]
        adj += 1
    else:
        pass

H = H - adj

for i in range(H):
    tinpo = ''.join(s[i])
    print(tinpo)

Solution (Python):
h,w = map(int, input().split())
a0 = [[] for i in range(h)]
for i in range(h):
  a0[i] = input()
a = [j for j in a0 if "
at0 = list(map(list, zip(*a)))
for k in range(len(at0)):
  at0[k] = "".join(at0[k])
at = [l for l in at0 if "
for m in list(map(list, zip(*at))):
  print("".join(m))

Solution (Python):
import numpy as np

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

gyo = np.all(hw == ".",axis=1)
retu= np.all(hw == ".",axis=0)

for i in range(H):
    if not gyo[i]==True:
        for j in range(W):
            if not retu[j]==True:
                print(hw[i][j],end="")
        print()

Solution (Python):

import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


H, W = zz()
board = []
for h in range(H):
    board.append(list(input()))
board = np.array(board)
ans1 = []
for h in range(H):
    if ('
        ans1.append(board[h])
ans2 = []
board = np.array(ans1)
for w in range(W):
    if ('
        ans2.append(board[:, w])
ans2 = np.array(ans2).T

for line in ans2:
    print(*line, sep='')

Solution (Python):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    h,w = LI()
    board = []
    for _ in range(h):
        line = list(S())
        board.append(line)
    
    wpro = []
    wline = ["." for _ in range(w)]

    for line in board:
        if line != wline:
            wpro.append(line)
    
    hpro = list(zip(*wpro))
    hline = tuple(["." for _ in range(len(hpro[0]))])
    
    ans = []
    
    for line in hpro:
        if line!= hline:
            ans.append(line)
    
    ans = list(zip(*ans))
    for line in ans:
        print("".join(line))
main()

Solution (Python):
import numpy as np

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

gyo = np.all(hw == ".",axis=1)
retu= np.all(hw == ".",axis=0)

for i in range(H):
	if not gyo[i]==True:
		for j in range(W):
			if not retu[j]==True:
				print(hw[i][j],end="")
		print()

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

res =[]

for i in range(h):
    if ab[i].count(".") ==w:
        pass
    else:
        res.append(ab[i])

l = len(res)

ress=[]
for j in range(w):
    b = list(map(lambda x: x[j], res))
    if b.count(".") ==l:
        pass
    else:
        ress.append(b)

ans = list(zip(*ress))

for i in range(l):
    print(''.join(ans[i]))

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


r = [0]*H  
for i in range(H):
    r[i]=a[i].count('

c = [0]*W  
for i in a:
    for j in range(W):
        if i[j]=='
            c[j]+=1
            
for i in range(H):
    a[i] = [a[i][j] for j in range(W) if c[j]!=0]


for i in range(H):
    if r[i]!=0:
        print(''.join(a[i]))

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

a=[list(map(str,input().split())) for i in range(H)]
for i in range(H):
    a[i]=list(a[i][0])
flag=True
for i in range(H):
    for j in range(W):
        if a[H-1-i][j]!='.':
            flag=False
            break
    if flag:
        del(a[H-1-i])
    flag=True
for i in range(W):
    for j in range(len(a)):
        if a[j][W-1-i]!='.':
            flag=False
            break
    if flag:
        for j in range(len(a)):
            del(a[j][W-1-i])
    flag=True

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

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial

from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

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

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

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]







h,w = MI()
a = LS(h)



rc = []
rr = []

for i in range(h):
    r = a[i]
    if r == ['.']*len(a[0]):
        rr.append(i)


na = []
for i in range(h):
    if i not in rr:
        na.append(a[i])


for i in range(w):
    c = mycol(na,i)
    if c == ['.']*len(na):
        rc.append(i)


ans = []
for i in range(len(na)):
    row = na[i]
    new_row = []
    for j in range(len(na[0])):
        if j not in rc:
            new_row.append(row[j])
    ans.append(new_row)


for i in range(len(ans)):
    myoutput(ans[i],space=False)

Solution (Python):
H,W=map(int,input().split())
a=[input() for _ in range(H)]
answers1=[]
for h in range(H):
    a1=a[h]
    if '
        answers1.append(a1)
answers2=['' for _ in range(len(answers1[0]))]
for answer in answers1:
    for n in range(len(answer)):
        answers2[n]+=answer[n]
answers=[]
for answer in answers2:
    if '
        answers.append(answer)
for x in range(len(answers[0])):
    kotae=''
    for y in range(len(answers)):
        kotae+=answers[y][x]
    print(kotae)

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

for i in range(h):
    row = list(input())
    if row != ["."]*w:
        cell.append(row)

counter = []
for i in range(w):
    flag = 0
    for j in range(len(cell)):
        if cell[j][i] == "
            flag = 1
            break
    if flag == 1:
            counter.append(i)

for a in cell:
    ans = ''
    for i in counter:
        ans = ans + a[i]
    print(ans)

Solution (Python):
H,W = map(int,input().split())
a = [input() for i in range(H)]
b = [0] * W
c = [0] * H
for i in range(H):
    cnt = 0
    for j in range(W):
        if a[i][j] == '
            b[j] += 1
            cnt += 1
    c[i] = cnt 

for i in range(H):
    if c[i]==0:
        continue
    for j in range(W):
        if b[j]!=0:
            print(a[i][j],end='')
    print()

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

grid = []
for _ in range(h):
    x = input()
    if x.count(".") != len(x):
        grid.append(x)

grid = list(map(list, zip(*grid)))

grid_t = []
for g in grid:
    if g.count(".") != len(g):
        grid_t.append(g)

ans = list(map(list, zip(*grid_t)))

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

Solution (Python):
h,w = map(int,input().split())
s = 0
li = []
lire = []
linew = []
for i in range(h):
    li.append(input())
for i in range(w):
    for j in range(h):
        if li[j][i] == ".":
            s = 1
        else:
            s = 0
            break
    if s == 1:
        lire.append(i)
        s = 0
for i in range(h):
    a = ""
    for j in range(w):
        if j not in lire:
            a += li[i][j]
    linew.append(a)
for i in range(len(linew)):
    if "
        continue
    else:
        print(linew[i])

Solution (Python):
h,w=map(int,input().split())
A=[]
ans=[]
for i in range(h):
    A.append(list(input()))
for a in A:
    if a != ['.']*w:
        ans.append(a)
counter=[]
for i in range(w):
    flag=0
    for j in range(len(ans)):
        if ans[j][i]=='
            flag=1
            break
    if flag==1:
        counter.append(i)
        
for a in ans:
    temp=''
    for i in counter:
        temp+=a[i]
    print(temp)

Solution (Python):
h,w=map(int,input().split())
A=[]
ans=[]
for i in range(h):
  A.append(list(input()))
for a in A:
  if a != ['.']*w:
    ans.append(a)
counter=[]
for i in range(w):
  flag=0
  for j in range(len(ans)):
    if ans[j][i]=='
      flag=1
      break
  if flag==1:
    counter.append(i)

for a in ans:
  tmp=''
  for i in counter:
    tmp=tmp+a[i]
  print(tmp)

Solution (Python):
N,M = map(int,input().split())
ls = []
for i in range(N):
    ls.append(list(input()))
yoko = []
tate = [i for i in range(M)]
for i in range(N):
    if ls[i].count('.') == M:
        yoko.append(i)
for i in range(N):
    for j in range(M):
        if ls[i][j] == '
            tate.remove(j)
tate2 = list(range(M))
for i in range(M):
    if i in tate:
        tate2.remove(i)

ansls = []
for i in range(N):
    if not i in yoko:
        ansls.append([ls[i][j] for j in tate2])
for i in ansls:
    print(''.join(i))

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

hl=[]
wl=[]

for i in range(h):
    if a[i]=="."*w:
        hl +=[i]
for i in range(w):
    if all([a[j][i]=="." for j in range(h)]):
        wl += [i]


for i in range(h):
    if i not in hl:
        for j in range(w):
            if j not in wl:
                print(a[i][j],end="")
        else:
            print("")

Solution (Python):
H,W=map(int,input().split())
L=[[] for i in range(H)]
yoko=list()
for i in range(H):
  L1=list(input())
  if L1==["."]*W:
    yoko.append(i)
  L[i]=L1
R=list(range(W))
for i in range(H):
  for j in range(W):
    if j in R and L[i][j]=="
      R.remove(j)
for i in range(H):
  if i in yoko:
    continue
  s=L[i]
  r=list()
  for j in range(W):
    if j not in R:
      r.append(s[j])
  print("".join(r))

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


ans = [""] * len(a)
for i in range(len(a[0])):
    flag = 0
    for j in range(len(a)):
        if a[j][i] == "
            flag = 1
    if flag == 1:
        for j in range(len(a)):
            ans[j] += a[j][i]
for i in range(len(ans)):
    print(ans[i])

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

tmp_h = [int(0) for i in range(h)]
tmp_w = [int(0) for j in range(w)]
for i in range(h):
    for j in range(w):
        if masu[i][j]=='.':
            tmp_h[i] += 1
            tmp_w[j] += 1



ans = []
for i in range(len(tmp_h)):
    if tmp_h[i] != w:
        tmp = ''
        for j in range(w):
            if tmp_w[j] != h:
                tmp += masu[i][j]
        ans.append(tmp)




for i in range(len(ans)):
    print(ans[i])

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

c = set()
for a in A:
    for i in range(W):
        if a[i] == '
            c.add(i)

for a in A:
    for i in range(W):
        if i in c:
            print(a[i], end='')
    print()

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

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

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

Solution (Python):
h, w = map(int, input().split())
a = [''] * h
for i in range(h):
	a[i] = input()
 
row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if a[i][j] == '
			row[i] = True
			col[j] = True
 
for i in range(h):
	if row[i]:
		for j in range(w):
			if col[j]:
				print(a[i][j], end = '')
		print()

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

h = len(a)

w_pass =[]
for i in range(w):
    for j in range(h):
        if a[j][i] != ".":
            break
    else:
        w_pass.append(i)

for i in range(h):
    line = ""
    for j in range(w):
        if j in w_pass:
            pass
        else:
            line += a[i][j]
    print(line)

Solution (Python):
import math

h, w = map(int, input().split(" "))
aL = [list(input()) for _ in range(h)]

for i in reversed(range(h)):
    if len(set(aL[i])) == 1 and aL[i][0][0] == ".":
        del aL[i]

for i in reversed(range(w)):
    for j in range(len(aL)):
        if aL[j][i] == "
            break
    else:
        for k in range(len(aL)):
            del aL[k][i]

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

Solution (Python):
H, W = map(int, input().split())
a = [input() for _ in range(H)]
for i in range(H):
    if a[i].count('
        s = ''
        for j in range(W):
            if [A[j] for A in a].count('
                s += a[i][j]
        print(s)

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

for i in range(h):
    line = list(input())
    if line != ["."] * w:
        masu.append(line)

h = len(masu)
del_i = []
for i in range(w):
    for j in range(h):
        if masu[j][i] != ".":
            break
    else:
        del_i.append(i)
w = len(del_i)
for j in range(w):
    for i in range(h):
        masu[i].pop(del_i[j] - j)

for i in range(h):
    print("".join(masu[i]))

Solution (Python):
h,w=map(int,input().split())
maze=[]
for i in range(h):
  x=list(input())
  if x.count('
    maze.append(x)
  else:
    h-=1
    
ans=['' for i in range(h)]
  
for i in range(w):
  cnt=0
  for j in range(h):
    if maze[j][i]=='
      cnt+=1
  if cnt!=0:
    for k in range(h):
      ans[k]+=maze[k][i]
  else:
    w-=1
      
for i in range(h):
  print(ans[i])

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

board=[]
for i in range(H):
  board_=list(input())
  board.append(board_)

for i in range(H):
  if all([board[i][j]  == '*' or board[i][j]  == '.' for j in range(W)]):
    board[i]=['*']*W

for j in range(W):
  if all([board[i][j] =='*' or board[i][j] =='.' for i in range(H) ]):
    for k in range(H):
      board[k][j]='*'

Board=[[] for i in range(H)]
for i in range(H):
  for j in range(W):
    if board[i][j]!='*':
      Board[i].append(board[i][j])

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

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

Solution (Python):
h,w=map(int,input().split())
l=[list(input()) for i in range(h)]
tate=[False]*h
yoko=[False]*w
for i in range(h):
    for j in range(w):
        if l[i][j]=="
            tate[i]=True
            yoko[j]=True
for i in range(h):
    if tate[i]:
        for j in range(w):
            if yoko[j]:
                print(l[i][j],end="")
        print()

Solution (Python):
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))

h, w = inm()
grid = []
for i in range(h):
    s = ins()
    if "
        grid.append(list(s))
remove = []
for i in range(w):
    tmp = True
    for x in grid:
        if x[i] == "
            tmp = False
            break
    if tmp:
        remove.append(i)
for i in remove[::-1]:
    for x in grid:
        x.pop(i)
for i in grid:
    print("".join(i))

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    H, W = map(int, readline().split())
    G = [readline().strip() for _ in range(H)]

    row = [False] * H
    col = [False] * W

    for i in range(H):
        for j in range(W):
            if G[i][j] == '
                row[i] = col[j] = True

    for i in range(H):
        if not row[i]:
            continue
        for j in range(W):
            if col[j]:
                print(G[i][j], end='')
        print('')

    return


if __name__ == '__main__':
    main()

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    H, W = map(int, readline().split())
    G = [readline().strip() for _ in range(H)]

    G = [row for row in G if row != '.' * W]
    G = list(''.join(row) for row in zip(*G))
    G = [row for row in G if row != '.' * len(row)]
    G = list(''.join(row) for row in zip(*G))

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

    return


if __name__ == '__main__':
    main()

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

pic = []
for i in range(H):
    a = list(input())
    if a != ["." for i in range(W)]:
        pic.append(a)

H = len(pic)
        
delete = [0 for i in range(W)]
for i in range(W):
    white = 0
    for j in range(H):
        if pic[j][i] == ".":
            white += 1
        if white == H:
            delete[i] += 1

for i in reversed(range(W)):
    if delete[i] == 1:
        for j in range(H):
            pic[j] = pic[j][0:i] + pic[j][i+1:]

for i in range(H):
    print(*pic[i], sep="")

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

h = {i: False for i in range(H)}
w = {i: False for i in range(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):
    s = ""
    for j in range(W):
        if h[i] and w[j]:
            s += A[i][j]

    if s != "":
        print(s)

Solution (Python):
import sys
import numpy as np


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    h, w = nm()
    A = np.array([list(ns()) for _ in range(h)])
    i = 0
    while i < len(A):
        if np.all(A[i] == '.'):
            A = np.delete(A, i, 0)
        else:
            i += 1

    j = 0
    while j < len(A[0]):
        if np.all(A[:, j] == '.'):
            A = np.delete(A, j, 1)
        else:
            j += 1
    for a in A:
        print(''.join(a))


if __name__ == '__main__':
    main()

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

tate = [False] * H
yoko = [False] * W

for h in range(H):
    for w in range(W):
        if HW_list[h][w] == '
            tate[h] = True
            yoko[w] = True

for h in range(H):
    tmp = ''
    for w in range(W):
        if tate[h] and yoko[w]:
            tmp += HW_list[h][w]
    if tmp == '':
        continue
    print(tmp)

Solution (Python):
a, b = map(int, input().split())
L = []
for i in range(a):
    l = input()
    if not l.count('.') == b:
        L.append(l)

M = []
for i in range(b):
    l = list(map(lambda x: x[i], L))
    if not l.count('.') == len(l):
        M.append(l)

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

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

for i in range(h):
    ls = input()
    if ls.count(".") == w:
        h_remove.append(i)
    k.append(ls)

for i in range(w):
    xx = ""
    for j in range(h):
        xx += k[j][i]
    if xx.count(".") == h:
        w_remove.append(i)

h_remove = set(h_remove)
w_remove = set(w_remove)
for i in range(h):
    ret = ""
    if i in  h_remove:
        continue
    else:
        for j in range(w):
            if j in w_remove:
                continue
            else:
                ret += k[i][j]
        print(ret)

Solution (Python):
h, w = map(int, input().split())
m = [[] for _ in range(h)]
x = [False] * h
y = [False] * w
for i in range(h):
    m[i] = list(input())
    if "
        x[i] = True
zm = list(zip(*m))
for i, j in enumerate(zm):
    if "
        y[i] = True
M = []
for i, H in enumerate(x):
    for v, W in enumerate(y):
        if H and W:
            M.append(m[i][v])
    if M:
        print("".join(M))
    M = []

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

x = []
for _ in range(H):
    a = [c for c in input()]
    if '
        x.append(a)

ans = []
for a in list(zip(*x)):
    if '
        ans.append(a)

for a in list(zip(*ans)):
    print(''.join(a))

Solution (Python):
H, W = map(int, input().split())
A = []
for _ in range(H):
    row = [{'.': 0, '
    if 0 < sum(row):
        A.append(row)
for x in range(W - 1, -1, -1):
    if sum(A[i][x] for i in range(len(A))) == 0:
        for y in range(len(A)):
            A[y][x:x + 1] = []
for row in A:
    print(''.join(['.' if v == 0 else '