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=[list(input()) for i in range(H)]
flag=True
while flag:
    if ['.']*W in a:
        a.remove(['.']*W)
        H-=1
    else:
        flag=False
flag=True
b=[[row[i] for row in a] for i in range(W)]
while flag:
    if ['.']*H in b:
        b.remove(['.']*H)
        W-=1
    else:
        flag=False
a=[[row[i] for row in b] for i in range(H)]
for i in range(H):
    s=''.join(a[i])
    print(s)

Solution (Python):
import copy
H,W=map(int,input().split())
a=[input() for i in range(H)]
flag=True
while flag:
    if '.'*W in a:
        a.remove('.'*W)
        H-=1
    else:
        flag=False
b=[0]*H
f=True
while f:
    c=copy.deepcopy(a)
    g=False
    for i in range(W):
        if g:
            break
        for j in range(H):
            b[j]=a[j][i]
        if ''.join(b)=='.'*H:
            for k in range(H):
                s=list(a[k])
                del s[i]
                a[k]=''.join(s)
            W-=1
            g=True
            break
    if c==a:
        f=False
for i in range(H):
    s=''.join(a[i])
    print(s)

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

for i in range(H):
  if a[i].count(".") == W:
    h[i] = False

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

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

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


for i in range(H):
    printed = False
    for j in range(W):
        if i not in row and j not in column:
            print(a[i][j], end="")
            printed = True
    if printed:
        print("")

Solution (Python):
H, W = map(int, input().split())
f = [list(input()) for _ in range(H)]
Y, X = [False for _ in range(H)], [False for _ in range(W)]
for y in range(H):
    for x in range(W):
        Y[y] |= f[y][x] == '
        X[x] |= f[y][x] == '
for y in range(H):
    flag = False
    for x in range(W):
        if Y[y] and X[x]:
            print(f[y][x], end = "")
            flag = True
    if flag:
        print()

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


for i in range(H):
  a0 = input()
  a1 = set(a0)
  a1 = list(a1)
  if(len(a1) != 1):
   a = list(a0)
   A.append(a) 
   count += 1
  else:
    if(a1[0] != '.'):
     a = list(a0)
     A.append(a) 
     count += 1 
    

j_pop = []
for j in range(W):
 B = [] 
 for i in range(count):  
  B.append(A[i][j])
 B = set(B)
 B = list(B)  
 
 if(len(B) == 1):
  if(B[0] == '.'):
    j_pop.append(j)  


for i in range(count): 
 ans ='' 
 for j in range(W):
  if(j in j_pop):
    continue
  else:
    ans += A[i][j]
 print(ans)

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

removable_y = [i for i in range(H)]
removable_x = [i for i in range(W)]

for y in range(H):
    removable = True
    for x in range(W):
        if Ai[y][x] != ".":
            removable = False
            break
    if not removable:
        removable_y.remove(y)

for x in range(W):
    removable = True
    for y in range(H):
        if Ai[y][x] != ".":
            removable = False
            break
    if not removable:
        removable_x.remove(x)

removable_x.reverse()
removable_y.reverse()

for y in removable_y:
    Ai = Ai[:y] + Ai[y + 1:]
for i in range(len(Ai)):
    txt = Ai[i]
    for x in removable_x:
        txt = txt[:x] + txt[x + 1:]
    Ai[i] = txt

for a in Ai:
    print(a)

Solution (Python):
n,m = map(int,input().split())

a = [list(input()) for i in range(n)]

h = []
l = []
co = 0
for i in range(n):
    co = 0
    for j in range(m):
        if a[i][j] == "
            co = 1
    if co == 0:
        l.append(i)
for i in range(m):
    co = 0
    for j in range(n):
        if a[j][i] == "
            co = 1
    if co == 0:
        h.append(i)

for i in range(len(l)):
    a.pop(l.pop())

for i in range(len(h)):
    p = h.pop()
    for j in range(len(a)):
        a[j].pop(p)

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

Solution (Python):
import numpy as np
from copy import deepcopy
H, W = map(int, input().split())
A = [list(input()) for _  in range(H)]

output = np.array(A)
A = np.array(A)
delcol = []
delrow = []

for i in range(H):
	if all([A[i][j]=='.' for j in range(W)]):
		delrow.append(i)
		continue
for j in range(W):
	if all([A[i,j]=='.' for i in range(H)]):
		delcol.append(j)

output = np.delete(output, delrow, 0)
output = np.delete(output, delcol, 1)

h, w = output.shape
for i in range(h):
	sentence = ''
	for j in range(w):
		sentence += output[i,j]
	print(sentence)

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

new_e = []
for row in e:
    if row.count("
        new_e.append(row)

use_col = []
for row in new_e:
    for col in range(W):
        if row[col] == "
            use_col.append(col)
            
for row in new_e:
    x=""
    for col in sorted(use_col):
        x += row[col]
    print(x)

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

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

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

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

Solution (Python):
h,w = map(int,input().split())
A = [input() for i in range(h)]
AnsH=[]
for i in range(h):
    if "
        AnsH.append(i)
AnsW=[]
for i in range(w):
    c = 0
    for j in range(h):
        if A[j][i]=="
            c = 1
    if c == 1:
        AnsW.append(i)
for i in AnsH:
    for j in AnsW:
        print(A[i][j],end="")

    print()

Solution (Python):
H, W = map(int, input().split())
grid = []
for i in range(H):
  line = input()
  for i in range(len(line)):
    if line[i] == '
      grid.append(line)
      break
gridans = [[''] for i in range(len(grid))]
for i in range(W):
  flag = 0
  for j in range(len(grid)):
    if grid[j][i] == '
      flag = 1
  if flag == 1:
    for j in range(len(grid)):
      gridans[j][0] += grid[j][i]
for i in range(len(gridans)):
  print(gridans[i][0])

Solution (Python):
from sys import stdin
H, W = map(int, input().split())
A = []
for _ in range(H):
    A.append([x for x in input()])
AT = list(zip(*A))
tate = []
yoko = []

for i in range(H):
    if '
        tate.append(i)
for i in range(W):
    if '
        yoko.append(i)

for i in tate:
    for j in yoko:
        print(A[i][j], end='')
    print('')

Solution (Python):

H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]
B = [[A[i][j] for i in range(H)] for j in range(W)]
check_H = sorted([i for i in range(H) if '
check_W = sorted([i for i in range(W) if '
for i in check_H:
    A = A[:i] + A[i + 1:]
for i in check_W:
    for j in range(len(A)):
        A[j] = A[j][:i] + A[j][i + 1:]
for a in A:
    print(''.join(a))

Solution (Python):

H,W = map(int,input().split(' '))
field = []

for i in range(H):
	field.append(str(input()))

def rotate(mat):
	
	mat_t = []
	if mat != []:
		for i in range(len(mat[0])):
			
			mat_t.append([])
		for i in range(len(mat[0])):
			
			for j in range(len(mat)):
				
				mat_t[i] += mat[j][i]
		for i in range(len(mat_t)):
			mat_t[i] = ''.join(mat_t[i])
	return mat_t

def white(n):
	return '.' * n

while white(W) in field:
    field.remove(white(W))
field_t = rotate(field)
while white(len(field_t[0])) in field_t:
    field_t.remove(white(len(field_t[0])))
field_t_t = rotate(field_t)

for s in field_t_t:
	print(s)

Solution (Python):
H, W = map(int,input().split())
HW = [input() for _ in range(H)]
HW = ["".join(hw) for hw in zip(*HW) if hw.count("
HW = ["".join(hw) for hw in zip(*HW) if hw.count("
print("\n".join(HW))

Solution (Python):
from collections import Counter
H,W=map(int,input().split())
a=[list(str(input())) for i in range(H)]
b=[]
n_H=0
for l in a:
    c=Counter(l)
    if c['.']!=W:
        b.append(l)
        n_H+=1
d=[]
b=list(map(list,zip(*b)))
for l in b:
    c=Counter(l)
    if c['.']!=n_H:
        d.append(l)
d=list(map(list, zip(*d)))

for l in d:
    s=''.join(l)
    print(s)

Solution (Python):
h, w = map(int, input().split())
a = [list(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=[]
for i in range(H):
    ai=input()
    if ai=="."*W:
        continue
    a.append(ai)
h=len(a)
def tenti(a):
    b=[]
    h=len(a)
    w=len(a[0])
    for i in range(w):
        bi=[]
        for j in range(h):
            bi.append(a[j][i])
        b.append(bi)
    return b
b=tenti(a)
h=len(b)
w=len(b[0])
c=[]
for i in range(h):
    if b[i]==["."]*w:
        continue
    c.append(b[i])
d=tenti(c)
for i in range(len(d)):
    for j in range(len(d[0])):
        if j==len(d[0])-1:
            print(d[i][j])
            break
        print(d[i][j],end="")

Solution (Python):
def grid_compression(H: int, W: int, A: list)->list:
    
    cols = []
    rows = []
    
    for h in range(H):
        all_white = True
        for w in range(W):
            if A[h][w] == '
                all_white = False
                break
        if not all_white:
            rows.append(h)

    
    for w in range(W):
        all_white = True
        for h in range(H):
            if A[h][w] == '
                all_white = False
                break
        if not all_white:
            cols.append(w)

    
    compressed = []
    for r in rows:
        compressed.append([])
        for c in cols:
            compressed[-1].append(A[r][c])

    return compressed


if __name__ == "__main__":
    H = 0
    H, W = map(int, input().split())
    A = [input() for _ in range(H)]
    ans = grid_compression(H, W, A)
    for row in ans:
        print(''.join(row))

Solution (Python):


import sys 

h,w = map(int, sys.stdin.readline().rstrip().split())
As = []
for i in range(h):
  As.append(str(sys.stdin.readline().rstrip()))

cnt_h = [0] * h
cnt_w = [0] * w

for i in range(h):
  for j in range(w):
    if As[i][j] == '.':
      cnt_h[i] += 1
      cnt_w[j] += 1

idx_h = []
for i in range(h):
  if cnt_h[i] < w:
    idx_h.append(i)

idx_w = []
for i in range(w):
  if cnt_w[i] < h:
    idx_w.append(i)

for i in idx_h:
  for j in idx_w:
    print(As[i][j], end="")
  print()

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

rows = set()
cols = set()
for j in range(W):
    for i in range(H):
        if a[i][j] == '
            rows.add(i)
            cols.add(j)
for j in rows:
    for i in cols:
        print(a[j][i], end='')
    print('')

Solution (Python):
def ans():
  H, W = map(int,input().split())
  HW = [input() for _ in range(H)]
  HW = ["".join(hw) for hw in zip(*HW) if hw.count("
  HW = ["".join(hw) for hw in zip(*HW) if hw.count("
  print("\n".join(HW))
ans()

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

def flip(arr):

    x = len(arr[0])
    y = len(arr)

    newArr = [[None] * y for _ in range(x)]
    for xi in range(x):
        for yi in range(y):
            newArr[xi][yi] = arr[yi][xi]
    return newArr

def main():

    m = M
    m = list(filter(lambda row: any([n == '
    m = flip(m)

    m = list(filter(lambda row: any([n == '
    m = flip(m)

    for row in m:
        print(''.join(row))
    
if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter
import numpy as np
H, W = map(int, input().split())
a = []
r_idx = []
c_idx = []

for i in range(H):
    line = list(input())
    ct = Counter(line).most_common()
    if not (ct[0][1] == W and ct[0][0] == "."):
        r_idx.append(i)
    a.append(line)
a = np.array(a).T

b = []
for i in range(W):
    ct = Counter(a[i]).most_common()
    if ct[0][1] == H and ct[0][0]==".":
        continue
    b.append(a[i])

b = np.array(b).T
c = []
for idx in r_idx:
    c.append(b[idx])

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

Solution (Python):
import numpy as np
H,W = map(int,input().split())
l = []
for i in range(H):
    tmp = input()
    if tmp.count('.') != W:
        l.append(list(tmp))
    else:
      	H-=1
l = np.array(l).T.tolist()
ans = []
for i in l:
  if i.count('.') != H:
    ans.append(i)
for i in np.array(ans).T:
  print(''.join(i))

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

grid = []
for i in range(H):
    grid.append(input())

grid_h = list(filter(lambda h: any([_ == '
remove_list = []
for w in range(W):
    for i, g in enumerate(grid_h):
        if g[w] == '
            break
        if i == len(grid_h) - 1:
            remove_list.append(w)
grid_hw = []
for g in grid_h:
    s = ''
    for i, c in enumerate(g):
        if i not in remove_list:
            s += c
    grid_hw.append(s)
for g in grid_hw:
    print(g)

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

a = ["".join(row) for row in zip(*a) if row.count("
a = ["".join(row) for row in zip(*a) if row.count("

print("\n".join(a))

Solution (Python):
h, w = map(int, input().split())
a=[list(input()) for i in range(h)]
def vert(a):
    res=[]
    for i in range(len(a)):
        if all(x=="." for x in a[i]):
            res.append(i)
    return res
def hori(a):
    res=[]
    for i in range(len(a[0])):
        if all(a[j][i]=='.' for j in range(len(a))):
            res.append(i)
    return res

while True:
    v_res=vert(a)
    if not(len(v_res)==0):
        a= [a[i] for i in range(len(a)) if not i in v_res]
            
    h_res=hori(a)
    if not(len(h_res)==0):
        a=[[a[j][i] for i in range(len(a[0])) if not i in h_res] for j in range(len(a))]
    if len(h_res+v_res)==0:
        break
for ai in a:
    print(''.join(ai))

Solution (Python):
h, w = map(int, input().split())
a = [list(map(int, list(input().replace('.', '0').replace('

h_list, w_list = [], []
for i in range(h):
    if sum(a[i]) > 0:
        h_list.append(i)
for j in range(w):
    if sum([aa[j] for aa in a]) > 0:
        w_list.append(j)
for i in h_list:
    print(''.join(['.','

Solution (Python):



def check(m, p):
    for i in range(len(m)):
        if m[i][p] == "
            return(False)
    return(True)


h, w = [int(x) for x in input().split()]
a = []
b = []
for i in range(h):
    a.append(input())
for i in a:
    if i.count("
        b.append(i)
r = []
for i in range(w):
    if check(b, i):
        r.append(i)
for i in range(len(b)):
    tmp = list(b[i])
    for p in r:
        tmp[p] = "*"
    print("".join(tmp).replace("*", ""))

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())
list_ = []
result = []
a = []
for i in range(H):
  tmp_set = list(input())
  if set(tmp_set) != {'.'}:
    list_.append(tmp_set)
    
for i in range(len(list_[0])):
  dot_ = 0
  a = [x[i] for x in list_]
  if set(a)!={'.'}:
    result.append(a)
    	
result = [list(x) for x in zip(*result)]
for i in result:
  print(''.join(i))

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

row=[False]*h
col=[False]*w

for i in range(h):
    for j in range(w):
        if a[i][j]=="
            row[i]=True
            col[j]=True;

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

Solution (Python):
H, W = map(int, input().split())
A = []
check = [0] * W

for i in range(H):
    row = input()
    if '
        continue
    else:
        for j in range(W):
            if row[j] == '
                check[j] += 1
        A.append(row)

for idx in range(len(A)):
    l_ = [a for i, a in enumerate(list(A[idx])) if check[i] != 0]
    A[idx] = ''.join(l_)

for l in A:
    print(l)

Solution (Python):
H, W = map(int, input().split())
a1 = []
for y in range(H):
    c = list(input())
    if '
        a1.append(c)
a2 = list(zip(*a1))
a3 = []
for x in range(W):
    r = a2[x]
    if '
        a3.append(r)
a4 = list(zip(*a3))
for r in a4:
    print(''.join(r))

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

row=[False]*h
col=[False]*w
for i in range(h):
    for k in range(w):
        if l[i][k]=="
            row[i]=True
            col[k]=True
for i in range(h):
    if row[i]:
        for k in range(w):
            if col[k]:
                print(l[i][k], end="")
        print("")

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

l = [input() for i in range(H)]

y = [False] * H
x = [False] * W

for i in range(H):
    flg = True
    for j in range(W):
        if l[i][j] != '.':
            flg = False
            break
    if flg:
        y[i] = True

for i in range(W):
    flg = True
    for j in range(H):
        if l[j][i] != '.':
            flg = False
            break
    if flg:
        x[i] = True

for i in range(H):
    if y[i]:
        continue
    for j in range(W):
        if x[j]:
            continue
        print(l[i][j], end='')
    print()

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

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

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

for i in range(H):
  l=input()
  if '
    tmp.append(l)

ans=[]
for l in zip(*tmp):
  if '
    ans.append(''.join(l))

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

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

def transpose(b):
  L,C=len(b),len(b[0])
  ret=[]
  for c in range(C):
    s=''
    for l in range(L):
      s+=b[l][c]
    ret.append(s)
  return ret

tmp=transpose(board)
ans=[]
for l in tmp:
  if '
    ans.append(l)

tmp=transpose(ans)
ans=[]
for l in tmp:
  if '
    print(l)

Solution (Python):
h,w = map(int, input().split())
a = []
row_check = []
for i in range(h): 
    tmp = list(input())
    a.append(tmp)
    if '
        row_check.append(i)
col_check = []
for i in range(w):
    columns =[]
    for j in range(h):
        columns.append(a[j][i])
    if '
        col_check.append(i)
res = []
for i in range(h):
    if i in row_check:
        tmp = []
        for j in range(w):
            if j in col_check:
                tmp.append(a[i][j])
        print(''.join(tmp))

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

for x in L[:]:
    if '
        continue
    else:
        L.remove(x)
L=list(map(list,zip(*L)))
for x in L[:]:
    if '
        continue
    else:
        L.remove(x)
        
L=list(map(list,zip(*L)))
for i in range(len(L)):
    print(''.join(L[i]))

Solution (Python):
def solve(string):
    h, w, *a = string.split()
    h = int(h)
    w = int(w)
    rows = [sum([_c == "
    cols = [sum([_a[i] == "
    ans = "\n".join(
        "".join([_c for __f, _c in zip(cols, _a) if __f]) for _f, _a in zip(rows, a) if _f)
    return ans


if __name__ == '__main__':
    n, w = map(int, input().split())
    print(solve('{} {}\n'.format(n, w) + '\n'.join([input() for _ in range(n)])))

Solution (Python):
h,w=map(int,input().split())
a=[]
for i in range(h):
    a.append(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]==True:
        for j in range(w):
            if c[j]==True:
                print(a[i][j],end='')
        print()

Solution (Python):


from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

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

a = [raw_input() for _ in range(H)]
f1 = [False] * H
f2 = [False] * W

for i in range(H):
    hoge = True
    for j in range(W):
        if a[i][j] == '
            hoge = False
    f1[i] = hoge

for i in range(W):
    hoge = True
    for j in range(H):
        if a[j][i] == '
            hoge = False
    f2[i] = hoge

for i in range(H):
    if f1[i]:
        continue
    S = ""
    for j in range(W):
        if not f2[j]:
            S += a[i][j]
    print S

Solution (Python):
h,w=map(int,input().split())
a=[input() for i in range(h)]
hi=[]
we=[]
def str_del(str,index):
    str = str[:index]+str[index+1:]
    return str

for i in range(h):

    if a[i] =='.'*w:
        we+=[i]

for i in range(w):
    memo=[]
    for j in range(h):
        memo+=a[j][i]
    if ''.join(memo) =='.'*h:
        hi+=[i]

for i in we[::-1]:
    a.pop(i)
for z in range(len(a)):
    for x in hi[::-1]:
        a[z]=str_del(a[z], x)

for i in a:
    print(i)

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

F = [False]*W
for y in range(H):
  for x in range(W):
    if a[y][x]=='
      F[x] = True
for y in range(H):
  if '
    l = ""
    for x in range(W):
      if F[x]:
        l += a[y][x]
    print l

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

    row = [False] * H
    col = [False] * W
    for i in range(H):
        for j in range(W):
            if a[i][j] == "
                row[i] = True
                col[j] = True

    for i in range(H):
        if row[i]:
            for j in range(W):
                if col[j]:
                    print(a[i][j], end="")
            print()


if __name__ == "__main__":
    main()

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


temp1 = []
temp2 = []
for i in range(len(a)):
	ff = 0
	for j in range(len(a[i])):
		if a[i][j] == '.':
			continue
		ff = 1
	if ff == 0:
		temp1.append(i)
temp1.sort(reverse=True)
for i in range(len(a[0])):
	ff = 0
	for j in range(len(a)):
		if a[j][i] == '.':
			continue
		ff = 1
	if ff == 0:
		temp2.append(i)
temp2.sort(reverse=True)
for i in range(len(temp1)):
	a.pop(temp1[i])
for i in range(len(temp2)):
	for k in range(len(a)):
		a[k].pop(temp2[i])

for i in range(len(a)):
	s = ''
	for j in range(len(a[i])):
		s += a[i][j]
	print(s)

Solution (Python):
f=lambda s:zip(*[t for t in s if'
for r in f(f(open(0).readlines())):print(*r,sep='')

Solution (Python):
f=lambda s:zip(*[t for t in s if'
for r in f(f(open(0).readlines())):print(*r,sep='')

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())
Ass = [input() for _ in range(H)]

numHs = [0] * H
numWs = [0] * W
for i in range(H):
    for j in range(W):
        if Ass[i][j] == '
            numHs[i] += 1
            numWs[j] += 1

for i in range(H):
    if numHs[i] == 0: continue
    Bs = []
    for j in range(W):
        if numWs[j]:
            Bs += Ass[i][j]
    print(''.join(Bs))

Solution (Python):
height,width=map(int,input().split())
masu = []
for i in range(height):
    a = input()
    if "
        masu.append(a)
N = [0]*width
for i in masu:
    for j in range(width):
        if i[j] == "." : N[j] += 1
number = []
for i in range(width):
    if N[i] != len(masu) : number.append(i)
result=[]
for i in range(len(masu)):
    a = ""
    for j in number:
        a+=masu[i][j]
    result.append(a)
for i in result:
    print(i)

Solution (Python):


"""
Created on Mon Feb 11 05:38:56 2019

@author: shinjisu
"""



import math


def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def dmp(x):
    global debug
    if debug:
        print(x)


debug = True


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


def prob096():  
    X = getIntList()
    K = getInt()
    dmp((X, K))
    total = sum(X) - max(X) + max(X)*2**K
    return total


def prob097():  
    X = getInt()
    dmp(X)
    if X == 1:
        return 1
    for n in range(X, 0, -1):
        dmp(n)
        for b in range(2, int(math.sqrt(X))+1):
            a = n
            exp = True
            while a > 1:
                if a % b != 0:
                    exp = False
                    break
                a //= b
            if exp:
                break
        if exp:
            break
    return n


def prob098():  
    N = getInt()
    S = input()
    dmp((N, S))
    maxChCount = 0
    for i in range(1, N):
        before = S[:i]
        after = S[i:]
        dmp((before, after))
        chCount = 0
        for j in range(26):
            ch = chr(ord('a')+j)
            if ch in before and ch in after:
                chCount += 1
        maxChCount = max(maxChCount, chCount)
    return maxChCount


def prob099():  
    a, b = getIntList()
    height = 0
    for i in range(b-a+1):
        height += i
    height -= b
    return height


def prob103():  
    S = input()
    T = input()
    for i in range(len(S)):
        S = S[1:] + S[0]
        dmp(S)
        if S == T:
            return 'Yes'
    else:
        return 'No'


def prob110():  
    N, M, X, Y = getIntList()
    cX = getIntList()
    cY = getIntList()
    dmp((N, M, X, Y))
    dmp(cX)
    dmp(cY)
    NW = 'No War'
    WA = 'War'
    if Y <= X:
        return WA
    cX.sort()
    cY.sort()
    dmp(cX)
    dmp(cY)
    if cX[-1] < cY[0] and \
            X < cY[0] and \
            cX[-1] < Y:
        return NW
    else:
        return WA


def prob109():  
    N = getInt()
    W = []
    for i in range(N):
        W.append(input())
    dmp(W)
    ALPHABET = [chr(i+ord('a')) for i in range(26)]
    NO = 'No'
    dmp(ALPHABET)
    used = set([W[0]])
    for i in range(1, N):
        dmp(used)
        if W[i] in used:
            return NO
        used.add(W[i])
        if W[i-1][-1] != W[i][0]:
            return NO
    return 'Yes'


def prob106():  
    N = getInt()
    div8Count = 0
    for i in range(1, N+1):
        divCount = 0
        for j in range(1, i+1):
            
            if i % j == 0:
                divCount += 1
        dmp((i,divCount))
        if divCount == 8 and i % 2 == 1:
            div8Count += 1
    return div8Count


def prob107():  
    H, W = getIntList()
    grid = []
    for i in range(H):
        grid.append(input())
    dmp((H,W))
    dmp(grid)
    WHITE = '.'
    i = 0
    while i < len(grid):
        for cell in grid[i]:
            if cell != WHITE:
                i += 1
                break
        else:
            grid.pop(i)
    dmp(grid)
    j = 0
    while j < len(grid[0]):
        for i in range(len(grid)):
            if grid[i][j] != WHITE:
                j += 1
                break
        else:
            for i in range(len(grid)):
                grid[i] = grid[i][:j] + grid[i][j+1:]
    return grid


def prob100():  
    return 0


debug = False  

w = prob107()
for row in w:
    print(row)

Solution (Python):
H, W = map(int, input().split())
L = []
for i in range(H):
    L.append(list(input()))
dH = []
for i in range(H):
    if L[i].count('.') == W:
        dH.append(i)
dW = []
for i in range(W):
    flag = True
    for j in range(H):
        if L[j][i] == '
            flag = False
            break
    if flag:
        dW.append(i)
for i in range(H):
    if i in dH:
        continue
    ans = []
    for j in range(W):
        if not j in dW:
            ans.append(L[i][j])
    print(''.join(ans))