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=[]
gyo=[False]*h
for i in range(h):
    line=input()
    a.append(line)
    if line.count(".")==w:
        gyo[i]=True
retsu=[False]*w
for i in range(w):
    cnt=0
    for j in range(h):
        if a[j][i]==".":
            cnt+=1
    if cnt==h:
        retsu[i]=True


for i in range(h):
    if gyo[i]==False:
        line=""
        for j in range(w):
            if retsu[j]:
                continue
            else:
                line+=a[i][j]
        print(line)

Solution (Python):
H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]
tmp = []
for h in range(H):
    if set(A[h]) != {'.'}:
        tmp.append(A[h])
H = len(tmp)
ans = [[] for _ in range(H)]

for w in range(W):
    if set(tmp[h][w] for h in range(H)) != {'.'}:
        for h in range(H):
            ans[h].append(tmp[h][w])

for h in range(H):
    print(''.join(map(str, ans[h])))

Solution (Python):
H, W = map(int, input().split())
a = [None]*H
b = [[1 for j in range(W)] for i in range(H)]
delete = 1
for i in range(0, H):
  a[i] = input()
for i in range(0, H):
  for j in range(0, W):
    if a[i][j] != ".":
      delete = 0
      break
  if delete == 1:
    for j in range(0, W):
      b[i][j] = 0
  else:
    delete = 1
for j in range(0, W):
  for i in range(0, H):
    if a[i][j] != ".":
      delete = 0
      break
  if delete == 1:
    for i in range(0, H):
      b[i][j] = 0
  else:
    delete = 1
new_line = 0
for i in range(0, H):
  for j in range(0, W):
    if b[i][j] == 1:
      print(a[i][j], end = '')
      new_line = 1
  if new_line == 1:
    print(" ")
    new_line = 0

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









def resolve():
    h, w = map(int, input().split())
    A = [[_ for _ in input()] for _ in range(h)]
    B = [i for i in A if '
    C = zip(*[i for i in zip(*B) if '
    for i in C:
        print(*i, sep='')

        


resolve()

Solution (Python):
def resolve():
    h, w = map(int, input().split())
    A = [[_ for _ in input()] for _ in range(h)]
    B = [i for i in A if '
    C = zip(*[i for i in zip(*B) if '
    for i in C:
        print(*i, sep='')

        


resolve()

Solution (Python):
import bisect
import copy
import fractions
import math
import numpy as np
from collections import Counter, deque
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product


def resolve():
    h, w = map(int, input().split())
    A = [[_ for _ in input()] for _ in range(h)]
    B = [i for i in A if '
    C = zip(*[i for i in zip(*B) if '
    
    for i in C:
        print(*i, sep='')


resolve()

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):
def main():
    h, w = map(int, input().split())
    str_list = []
    for _ in range(h):
        str_list.append(list(input().split()))

    for i in range(h):
        for j in range(w):
            if str_list[i][0][j] != '.':
                break
        else:
            for _ in range(w):
                str_list[i][0] = '!' * w
                
    delete_index_list = []

    for i in range(w):
        for j in range(h):
            if str_list[j][0][i] != '.' and str_list[j][0][i] != '!':
                break
        else:
            delete_index_list.append(i)

    for i in range(h):
        for j in range(w):
            if j in delete_index_list:
                continue
            if str_list[i][0][j] != '!':
                print(str_list[i][0][j], end='')
            else:
                break
        else:
            print()


if __name__ == '__main__':
    main()

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):
def is_space(iterable):
    return all(map(lambda x: x == ".", iterable))


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

remove_row_idx = []
for idx, row in enumerate(A):
    if is_space(row):
        remove_row_idx.append(idx)

for count, idx in enumerate(remove_row_idx):
    del A[idx - count]

remove_column_idx = []
for i in range(W):
    column = [r[i] for r in A]
    if is_space(column):
        remove_column_idx.append(i)

for count, idx in enumerate(remove_column_idx):
    for row in A:
        del row[idx - count]

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

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

L = []
for i in range(h):
    tmp = list(input())
    if tmp != ["."]*len(tmp):
        L.append(tmp)
    else:
        h -= 1

l_2d_t = [list(x) for x in zip(*L)]

new_L = []
for i in l_2d_t:
    if i != ["."]*len(i):
        new_L.append(i)

l_2d_t = [list(x) for x in zip(*new_L)]

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

Solution (Python):
H,W=map(int,input().split())
a=[input() for i in range(H)]
useh=[True]*H
usew=[True]*W
for h in range(H):
    cnt=0
    for w in range(W):
        if a[h][w]=='.':
            cnt+=1
    if cnt==W:
        useh[h]=False
for w in range(W):
    cnt=0
    for h in range(H):
        if a[h][w]=='.':
            cnt+=1
    if cnt==H:
        usew[w]=False
for h in range(H):
    if useh[h]:
        for w in range(W):
            if usew[w]:
                print(a[h][w],end='')
        print()

Solution (Python):

import pprint

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


row_del_list=[]
for i,v in enumerate(a_list):
    if v.count(".") == W:
        row_del_list.append(i)

for i in row_del_list[::-1]:
    del a_list[i]
    H -= 1

       
column_del_list=[]
for j in range(W):
    cnt_white=0
    for i in range(H):
        if a_list[i][j] == ".":
            cnt_white += 1
    
    if cnt_white == H:
        column_del_list.append(j)
        
for j in column_del_list[::-1]:
    for i in range(H):
        del a_list[i][j]
        W -= 1


for row in a_list:
    print(*row,sep="")

Solution (Python):
H,W=map(int,input().split(' '))
a = [list(input()) for i in range(H)]
tmp = []
ans = []
for i in a:
    if i != ['.']*W:
        tmp.append(i)
for i in range(W):
    l = [tmp[j][i] for j in range(len(tmp))]
    if l != ['.']*len(tmp):
        ans.append(l)
for i in range(len(ans[0])):
    print(''.join([ans[j][i] for j in range(len(ans))]))

Solution (Python):
h,w = map(int,input().split())
a = [input() for _ in range(h)]
for i in range(h-1,-1,-1):
    if set(a[i])=={'.'}: a.remove(a[i])
for i in range(w-1,-1,-1):
    ok = True
    for j in range(len(a)):
        if a[j][i]=='
    if ok:
        for j in range(len(a)):
            a[j] = a[j][:i]+a[j][i+1:]
[print(i) for i in a]

Solution (Python):


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

a = [i for i in a if "

b = [("").join(list(i)) for i in list(zip(*a))]

b = [i for i in b if "

c = [("").join(list(i)) for i in list(zip(*b))]

for i in c:
    print(i)

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

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

for i in range(H):
  for j in range(W):
    if grid[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(grid[i][j], end="")
    print()

Solution (Python):
h,w = map(int,input().split())
a = []
list_w = []
list_h = []
for i in range(h):
    A = list(str(input()))
    a.append(A)
for i in range(h):
    cnt_w = 0
    cnt_h = 0
    for j in range(w):
        if a[i][j] == ".":
            cnt_w += 1
    if cnt_w == w:
        list_w.append(i)

for i in range(w):
    cnt_h = 0
    for j in range(h):
        if a[j][i] == ".":
            cnt_h += 1
    if cnt_h == h:
        list_h.append(i)

for i in list_w:
    for j in range(w):
        a[i][j] = "!"
for i in list_h:
    for j in range(h):
        a[j][i] = "!"


ans = []
for i in range(h):
    tmp = []
    for j in range(w):
        if a[i][j] == "
            tmp.append(a[i][j])
    tmp = "".join(tmp)
    ans.append(tmp)
for i in ans:
    if i != '':
        print(i)

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

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())
mas = [list(input()) for i in range(H)]
new_mas = [row for row in mas if "
new_mas2 = [column for column in list(zip(*new_mas)) if "
for i in list(zip(*new_mas2)):
    for j in i:
        print(j,end="")
    print()

Solution (Python):
H,W = map(int,input().split())
mas = [list(input()) for i in range(H)]
new_mas = [row for row in mas if "
new_mas2 = [column for column in list(zip(*new_mas)) if "
for i in list(zip(*new_mas2)):
    for j in i:
        print(j,end="")
    print()

Solution (Python):
H,W = map(int,input().split())
mas = [list(input()) for i in range(H)]
new_mas = []
new_mas2 = []
for row in mas:
    if "
        new_mas.append(row)
    elif "
        continue

for column in list(zip(*new_mas)):
    if "
        new_mas2.append(column)
    elif "
        continue

for i in list(zip(*new_mas2)):
    for j in i:
        print(j,end="")
    print()

Solution (Python):
H,W = map(int,input().split())
mas = [list(input()) for i in range(H)]
new_mas = []
new_mas2 = []
for row in mas:
    if "
        new_mas.append(row)
    elif "
        continue

for column in list(zip(*new_mas)):
    if "
        new_mas2.append(column)
    elif "
        continue

for i in list(zip(*new_mas2)):
    for j in i:
        print(j,end="")
    print()

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

tate=[[False]*W for i in range(H)]
yoko=[[False]*W for i in range(H)]

for i in range(H):
    if('
        for j in range(W):
            yoko[i][j]=True
for j in range(W):
    for i in range(H):
        if(a[i][j]=='
            for k in range(H):
                tate[k][j]=True
            continue
for i in range(H):
    for j in range(W):
        if(tate[i][j] and yoko[i][j]):
            print(a[i][j],end='')
    if(yoko[i]!=[False]*W):
        print()

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

A = [a for a in A if ('
A = [a for a in zip(*A) if ('
A = zip(*A)

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

Solution (Python):
import numpy as np

Height, Width = map(int, input().split())
mat = [[0 for i in range(Width)] for j in range(Height)]

for h in range(Height):
    a = input()
    
    for w in range(Width):
        if (a[w] == '.'):
            mat[h][w] = 0
        else:
            mat[h][w] = 1

mat = np.array(mat)

h_sur = []
w_sur = []

for h in range(Height):

    if (1 in mat[h]):
        h_sur.append(h)


for w in range(Width):

    if (1 in mat[:, w]):
        w_sur.append(w)


convert_w = len(w_sur)
convert_h = len(h_sur)

convert_mat = [[-1 for i in range(convert_w)] for j in range(convert_h)]
convert_mat=np.array(convert_mat)


for h_index, h in enumerate(h_sur):

    for w_index, w in enumerate (w_sur):

        convert_mat[h_index][w_index] = mat[h][w]


for i in range(convert_h):
    
    s=''
    for j in range(convert_w):
        if (convert_mat[i][j] == 1):
            s += '
        else:
            s += '.'
    
    print(s)

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

A=[a for a in A if '
A=zip(*[a for a in zip(*A) if '

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

Solution (Python):
import numpy as np

n, m = map(int, input().split())
data = []
for _ in range(n):
    d = []
    for s in input():
        if s == '
            d.append(1)
        else:
            d.append(0)
    data.append(d)
data = np.array(data)
col = np.sum(data, axis=1)
row = np.sum(data, axis=0)

for i in range(n):
    if col[i] == 0: continue
    for j in range(m):
        if row[j]==0: continue
        s = '
        print(s, end='')
    print()

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 = (int(x) for x in input().split())
ab = []
counth = 0
for _ in range(h):
    a = input()
    a = list(a)
    if '
        counth += 1
        continue
    ab.append(a)
countw =[] 
for i in range(w):
    memo = 0
    
    for j in range(h-counth):
        if ab[j][i] == '.':
            memo += 1
            if memo == h-counth:
                countw.append(i)
countw.sort(reverse=True)
for j in countw:
    for i in range(h-counth):
        del ab[i][j]

for i in range(h-counth):
    print(''.join(ab[i]))

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

l=[i for i in l if '
l=[list(i) for i in zip(*l)]
l=[i for i in l if '
l=[list(i) for i in zip(*l)]

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

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

ans_h = []
for h in range(H) :
    flag = False
    for w in range(W) :
        if S[h][w] == "
            flag = True
    if flag == True :
        ans_h.append(h)

ans_w = []
for w in range(W) :
    flag = False
    for h in range(H) :
        if S[h][w] == "
            flag = True
    if flag == True :
        ans_w.append(w)

for h in ans_h :
    for w in ans_w :
        print(S[h][w], end="")
    print("")

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

tate = []
yoko = []
for i in range(h):
    for j in range(w):
        if a[i][j] == "
            yoko.append(i)
            tate.append(j)

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

Solution (Python):
H, W = map(int, input().split())
a_li = [input() for i in range(H)]
li = []
for i in range(H) :
    if "
        li.append(a_li[i])
del_nums = []
for i in range(W) :
    col_li = [row[i] for row in li]
    if not "
        del_nums.append(i)
for l in li :
    for i in range(W) :
        if not i in del_nums :
            print(l[i],end="")
    print()

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

del_row="."*W

for i in range(len(a)):
    row=a.pop(0)
    if row!=del_row:
        a.append(row)

del_col="."*len(a)
del_list=[]
for w in range(W):
    string=""
    for h in range(len(a)):
        string+=str(a[h][w])
    if string==del_col:
        del_list.append(w)

ans_list=[]
for h in range(len(a)):
    string=""
    for w in range(W):
        if not w in del_list:
            string+=a[h][w]
    ans_list.append(string)

for i in ans_list:
    print(i)

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

S=[""]*H

for i in range(H):
    S[i]=input()

isWw=[0]*W
isWh=[0]*H

for i in range(H):
    for k in range(W):
        if(S[i][k]=='
            isWw[k]=1
            isWh[i]=1


for i in range(H):
    if(isWh[i]==0):
        continue
    for k in range(W):
        if(isWw[k]==1):
            print(S[i][k],end='')
    print()

Solution (Python):
H, W = map(int, input().split())
cells = []
for _ in range(H):
    a = list(input())
    try:
        idx = a.index('
        cells.append(a)
    except:
        pass

cells = list(zip(*cells))

ans = []
for cell in cells:
    try:
        idx = cell.index('
        ans.append(cell)
    except:
        pass
ans = list(zip(*ans))

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

Solution (Python):

def main():

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

    mat = []
    for _ in range(H):
        A = input()

        flag = False
        for a in A:
            if a != '.':
                flag = True
        if flag:
            mat.append(A)

    l = []
    for i in range(W):
        flag = True
        for ary in mat:
            if ary[i] != '.':
                flag = False
                break
        if not flag:
            l.append(i)

    for s in mat:
        for i in l:
            print(s[i], end="")
        print()

main()

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):
import numpy as np

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

b = []
c = []
cnt = 0

for i in range(h):
    if set(a[i]) != {'.'}:
        b.append(a[i])
        cnt += 1

b = np.array(b)
b =b[::-1,:].T
b = list(b)

for j in range(w):
    if set(b[j]) != {'.'}:
        c.append(b[j])

c = np.array(c)
c = c[::-1,:].T
c = c[::-1,::-1]
c = list(c)

for i in range(cnt):
    print(''.join(map(str, c[i])))

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    h,w=INTM()
    a=[]
    wd=[]
    for i in range(h):
        temp=STR()
        if temp!='.'*w:
            a.append(temp)
    h=len(a)
    for i in range(w):
        flg=1
        for j in range(h):
            if a[j][i]=='
                flg=0
        if flg==1:
            wd.append(i)
    wd=sorted(wd,reverse=True)
    for i in wd:
        for j in range(h):
            
            a[j]=a[j][:i]+a[j][i+1:]
    for i in range(h):
        print(a[i],sep='')
        
    
if __name__ == '__main__':
    do()

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

flags=[False]*W

for i in range(H):
  for j in range(W):
    if a[i][j] != '.':
      flags[j]=True

for i in range(len(b)):
  tmp=[]
  for j in range(W):
    if flags[j]:
      tmp.append(b[i][j])
  print(''.join(tmp))

Solution (Python):
import math


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


def nCr(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r)


h, w = map(int, input().split())
a = [None]*h

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

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


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


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

Solution (Python):
H, W = map(int, input().split())
a = []
for _ in range(H):
    t = list(input())
    if t.count('.') != W:
        a.append(t)
    











for i in range(W):
    y_white = True
    for j in range(len(a)):
        if a[j][i] == '
            y_white = False
    if y_white:
        for j in range(len(a)):
            a[j][i] = ''

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

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

for y in range(H):
    for x in range(W):
        if a[y][x] == '
            yck[y] = 0
            xck[x] = 0
for y in range(H):
    if yck[y]: continue
    ans = ''
    for x in range(W):
        if xck[x]: continue
        ans += a[y][x]
    print(ans)

Solution (Python):
h,w = [int(x) for x in input().split()]
a = []
for _ in range(h):
    tmp = list(input())
    if set(tmp) != set("."):
        a.append(tmp)

for i in range(w):
    save = False
    for y in range(len(a)):
        if a[y][i] == '
            save = True
            break
    if not save:
        for y in range(len(a)):
            a[y][i] = '0'

for x in a:
    print(*[z for z in x if z != '0'],sep="")

Solution (Python):
h, w = map(int, input().split())
al = list(list(input()) for _ in range(h))
row = [False] * w
col = [False] * h

for i in range(h):
    for j in range(w):
        if al[i][j] == '
            col[i] = True
            row[j] = True
ans = []
w_len = len(row) - row.count(False)
for i in range(h):
    tmp = ''
    if col[i]:
        for j in range(w):
            if row[j]:
                tmp += al[i][j]
        ans.append(tmp)

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

Solution (Python):
h, w = map(int, input().split())
al = list(list(input()) for _ in range(h))
row = [0]*w
col = [0]*h

for i in range(h):
    for j in range(w):
        if al[i][j] == '
            col[i] += 1
            row[j] += 1
ans = []
w_len = len(row) - row.count(0)
for i in range(h):
    tmp = ''
    if col[i] != 0:
        for j in range(w):
            if row[j] != 0:
                tmp += al[i][j]
        ans.append(tmp)

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

Solution (Python):
import numpy as np

h, w = map(int, input().split())
al = list(list(input()) for _ in range(h))
al_n = np.array(al)
row = [0]*w
col = [0]*h
for i in range(h):
    for j in range(w):
        if al_n[i][j] == '.':
            row[j] += 1
            col[i] += 1
row_ = []
col_ = []
for i in range(w):
    if row[i] == h:
        row_.append(i)

for j in range(h):
    if col[j] == w:
        col_.append(j)

if len(col_) > 0:
    al_n = np.delete(al_n, col_, axis=0)

if len(row_) > 0:
    al_n = np.delete(al_n, row_, axis=1)

for a in al_n:
    print(*a, sep='')

Solution (Python):
h,w=map(int,input().split())
data=[]
count_x=[0]*w
count_y=[0]*h
for i in range(h):
    a_i=input()
    for j in range(w):
        if a_i[j]=="
            count_y[i]+=1
            count_x[j]+=1
    data.append(a_i)
for i in range(h):
    if count_y[i]!=0:
        data_i=data[i]
        ans=""
        for j in range(w):
            if count_x[j]!=0:
                ans+=data_i[j]
        print(ans)

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

dcomi={}
dcomj={}
for i in range(H):
    lsa.append(input())
for i in range(H):
    for j in range(W):
        if lsa[i][j]=="
            break
    else:
        dcomi[i]=1
for j in range(W):
    for i in range(H):
        if lsa[i][j]=="
            break
    else:
        dcomj[j]=1
for i in range(H):
    for j in range(W):
        if (not i in dcomi) and (not j in dcomj):
            print(lsa[i][j],end="")
    if not i+1 in dcomi:
        print()

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

for i in range(h):
    b=list(input())
    if '
        for j in range(w):
            a[j][i]=b[j]

    
c=0
for i in range(0-c,w-c):
    if '
        for j in range(h):
            a[i][j]=0
for i in range(h):
    for j in range(w):
        if a[j][i]!=0:
            print(a[j][i],end="")
            c+=1
    if c!=0:
        print()
    c=0

Solution (Python):
n,m=map(int,input().split())
L=[]
d=set(".")
for i in range(n):
  s=input()
  if set(list(s))!=d:
    L.append(list(s))
l=[list(a) for a in  zip(*L) if set(a)!=set(".")]
for a in zip(*l):
  print("".join(a))

Solution (Python):
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
nsl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

H, W = na()
m = nsl(H)

for i in range(W):
    flag = True
    for j in range(H):
        if m[j][i] != '.':
            flag = False
    if flag:
        for j in range(H):
            m[j][i] = '$'

for i in range(H):
    flag = True
    for j in range(W):
        if m[i][j] != '.' and m[i][j] != '$':
            flag = False
    if flag:
        for j in range(W):
            m[i][j] = '$'

o = [[] for i in range(H)]
for i in range(H):
    for j in range(W):
        if m[i][j] != '$':
            o[i].append(m[i][j])

for i in o:
    if len(i) >= 1:
        for j in i:
            print(j, end="")
        print()

Solution (Python):

H,W=map(int,input().split())
A=[]
for _ in range(H):
    S=input()
    if set(S)=={'.'}:
        continue
    A.append(list(S))
for w in range(W-1,-1,-1):
    flg=True
    for h in range(len(A)):
        if A[h][w]=='
            flg=False
    if flg:
        for h in range(len(A)):
            A[h].pop(w)

for s in A:
    print(''.join(s))

Solution (Python):
import numpy
h,w = map(int, input().split())
l = list()
for i in range(h):
    l.append(list(input()))
l = numpy.array(l)
kari = 0
kari2 = []
for i in range(h):
    for j in range(w):
        if l[i][j] == ".":
            kari += 1
    if kari == w:
        kari2.append(i)
    kari = 0
kari2 = kari2[::-1]
h -= len(kari2)
for i in kari2:
    l = numpy.delete(l, i, 0)
kari2 = []
for i in range(w):
    for j in range(h):
        if l[j][i] == ".":
            kari += 1
    if kari == h:
        kari2.append(i)
    kari = 0
kari2 = kari2[::-1]
for i in kari2:
    l = numpy.delete(l, i, 1)
l = l.tolist()
for i in range(h):
    print(*l[i],sep="")

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

f = f[~np.all(f=='.', axis=1), :]
f = f[:, ~np.all(f=='.', axis=0)]

print('\n'.join(''.join(row) for row in f))

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

a = [['x'] * w for i in range(h)]
for i in range(h):
    tmp = list(str(input()))
    for j in range(w):
        a[i][j] = tmp[j]


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

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

arr = []
for i in range(h):
    if a[i][0] == 'x':
        pass
    else:
        arr.append(a[i])


s = [len(v) for v in arr]
h = len(s)
w = s[0]

for i in range(w):
    flag = True
    for j in range(h):
        if arr[j][i] == '
            flag = False

    if flag:
        for j in range(h):
            arr[j][i] = 'x'

for i in range(h):
    for j in range(w):
        if arr[i][j] != 'x':
            print(arr[i][j], end='')
    print('')

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

for i in range(h-1,-1,-1):
    if set(a[i]) == {'.'}:
        del a[i]

for j in range(w-1,-1,-1):
    cnt = 0
    for k in range(len(a)):
        if a[k][j] == '.':
            cnt += 1
    if cnt == len(a):
        for l in range(len(a)):
            del a[l][j]
for i in a:
    print("".join(i))

Solution (Python):
h, w = map(int, input().split())
mass = [input() for _ in range(h)]
for i in reversed(range(h)):
    if mass[i].count("
        mass = mass[:i] + mass[i+1:]

for i in reversed(range(w)):
    cnt = 0
    for row in mass:
        if row[i] == "
            cnt += 1
    if cnt == 0:
        for j, row in enumerate(mass):
            mass[j] = row[:i] + row[i+1:]

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

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

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

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

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

for i in range(h):
    for j in range(w):
        if a[i][j]=='
            r[i]=1
            c[j]=1
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 = [input() for _ in range(H)]

ans = [ch for ch in a if "
ans = [ch for ch in zip(*ans) if "
ans = [ch for ch in zip(*ans)]

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

Solution (Python):
h, w = map(int, input().split())
table = []
for i in range(h):
    tmp = input()
    if tmp != '.' * w:
        table.append(tmp)
ans = []
for s in zip(*table):  
    if '
        ans.append(s)
for a in zip(*ans):  
    print(''.join(a))

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


lis=[]
for i in range(h):

    a = list(input())
    if '
        lis.append(a)
lis2=list(zip(*lis))
lis_ans=[]
for i in range(w):
    if '
        lis_ans.append(lis2[i])
lis_ans = list(zip(*lis_ans))


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

Solution (Python):
h, w = (int(x) for x in input().split())
a = [[0 if x == "." else 1 for x in input()] for _ in range(h)]
l = []
for i in range(h):
    if sum(a[i][:]) == 0: l.append(i)
if len(l) != 0:
    l = l[::-1]
    for l_i in l:
        a.pop(l_i)
l = []
for i in range(w):
    s = 0
    for j in range(len(a)):
        s += a[j][i]
    if s == 0: l.append(i)
if len(l) != 0:
    l = l[::-1]
    for l_i in l:
        for i in range(len(a)):
            a[i].pop(l_i)
ans = [["
for ans_i in ans:
    print("".join(ans_i))