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())
H_cnt = 0
maze = ["" for _ in range(W)]
maze_ok = [True]*W
for _ in range(H):
  m = input()
  if m != "."*W:
    for i in range(W):
      maze[i] += m[i]
  else:
    H_cnt += 1
for i in range(W):
  if maze[i]=="."*(H-H_cnt):
    maze_ok[i]=False

ans = ["" for _ in range(H-H_cnt)]
for i in range(H-H_cnt):
  for j in range(W):
    if maze_ok[j]:
      ans[i] += maze[j][i]

for a in ans:
  print(a)

Solution (Python):
h, w = map(int, input().split())
a = []
delcol = {i: True for i in range(w)}
for _ in range(h):
    _a = input()
    if _a == "."*w:
        continue

    for _w in range(w):
        delcol[_w] &= ("." == _a[_w])

    a.append(_a)

for _a in a:
    for _w in range(w):
        if not delcol[_w]:
            print(_a[_w], end="")

    print()

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

yoko = [False] * H
for i in range(H) :
    k = set()
    for j in range(W) :
        k.add(a[i][j])
    if len(k) == 1 and '.' in k :
        yoko[i] = True
        
tate = [False] * W
for i in range(W) :
    k = set()
    for j in range(H) :
        k.add(a[j][i])
    if len(k) == 1 :
        tate[i] = True
        
for i in range(H) :
    if yoko[i] : 
        continue
    s = ''
    for j in range(W) :
        if tate[j] and '.' in k :
            continue
        s += a[i][j]
    print(s)

Solution (Python):
import numpy as np

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

ans = []
for i in range(h):
    a = ''
    for j in range(w):
        if '
            a += A[i][j]
    if a != '':
        ans.append(a)

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

Solution (Python):
H,W = map(int,input().split())
h = [0]*H
w = [0]*W
l = [list(input()) for i in range(H)]
for i in range(H):
    if all([i=='.' for i in l[i][:]]):
        h[i]=1
lt = list(zip(*l))
for j in range(W):
    if all([j=='.' for j in lt[j][:]]):
        w[j]=1
for i in range(H):
    for j in range(W):
        if h[i]==0 and w[j]==0:
            print(l[i][j],end='')
    if h[i]==0:
        print()

Solution (Python):
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))

def main():
  h, w = na()
  a = [ns() for _ in range(h)]
  a = ["".join(hw) for hw in zip(*a) if hw.count("
  a = ["".join(hw) for hw in zip(*a) if hw.count("
  print("\n".join(a))

main()

Solution (Python):
h,w = map(int,input().split())
a = [list(map(str,input())) for _ in range(h)]
cnt = h
for i in range(h):
    if '
        a[i].clear()
        cnt -= 1
if cnt != h:
    a = [_ for _ in a if _]
i = 0
while i < w:
    for j in range(cnt):
        if a[j][i] == '
            break
    else:
        for j in range(cnt):
            a[j].pop(i)
        w -= 1
        i -= 1
    i += 1
for i in range(cnt):
    print(''.join(map(str,a[i])))

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

x=[input() for _ in range(h)]
y=[x[i] for i in range(h) if '
      
c=[]
for i in range(len(y)):
      for j in range(w):
            if y[i][j]=='
                  c.append(j)
d=list(set(c))
z=[]
for i in range(len(y)):
      w=[]
      for j in d:
            w.append(y[i][j])
      z.append(w)

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

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

li = []
for i in range(h):
    str = list(input())  
    li.append(str)

flg = True



for i in range(w):
    flg2 = True
    for j in range(h):
        if li[j][i] == "
            flg2 = False
            break
    
    if flg2:
        for j in range(h):
            li[j][i] = "a"

for i in range(h):
    flg2 = True
    for j in range(w):
        if li[i][j] == "
            flg2 = False
            break
    if flg2:
        for j in range(w):
            li[i][j] = "a"

    
for i in range(h):
    flg3 = False
    for j in range(w):
        if li[i][j] != "a":
            print(li[i][j], end ="")
            flg3=True
    
    if flg3:
        print()

Solution (Python):
h, w = map(int, input().split(' '))
a = [list(str(input())) for _ in range(h)]
checker = []
for i in range(len(a)):
    if all(x == '.' for x in a[i]):
        checker.append(i)
    else:
        continue
for i in range(1, len(checker)+1):
    a.pop(checker[-i])
checker = []
for i in range(len(a[0])):
    if all(a[j][i] == '.' for j in range(len(a))):
        checker.append(i)
    else:
        continue
for i in range(1, len(checker)+1):
    for j in range(len(a)):
        a[j].pop(checker[-i])


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

Solution (Python):
import numpy as np

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

a = [a[idx] for idx in range(len(a)) if a[idx].count(".") < len(a[idx])]
a = np.array(a).T.tolist()
a = [a[idx] for idx in range(len(a)) if a[idx].count(".") < len(a[idx])]
a = np.array(a).T.tolist()

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

Solution (Python):
import numpy as np

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

def del_blank_row(a):
    del_flg = []
    for row in range(len(a)):
        if a[row].count(".") == len(a[row]):
            del_flg.append(1)
        else:
            del_flg.append(0)
    a = [a[idx] for idx in range(len(a)) if del_flg[idx] == 0]
    return a

a = del_blank_row(a)
a = np.array(a).T.tolist()
a = del_blank_row(a)
a = np.array(a).T.tolist()

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

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

for _ in range(H):
    row = list(input())
    if "
        A.append(row)

for i in range(W):
    if "
        for a in A:
            a[i] = None

for a in A:
    for i in range(W):
        s = a[i]
        if s != None:
            print(s, end="")
    print()

Solution (Python):
import numpy as np

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

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

for h in range(H):
    for w in range(W):
        if A[h, w] == "
            break
        if w == W-1:
            row[h] = True

for w in range(W):
    for h in range(H):
        if A[h, w] == "
            break
        if h == H-1:
            column[w] = True

for r, is_deleted in reversed(list(enumerate(row))):
    if is_deleted:
        A = np.delete(A, r, 0)

for c, is_deleted in reversed(list(enumerate(column))):
    if is_deleted:
        A = np.delete(A, c, 1)

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

Solution (Python):
H, W = map(int, input().split())
matrix = []
ans = []
for i in range(H):
    h = list(input())
    if "
        matrix.append(h)
for j in range(W):
    w = [w_[j] for w_ in matrix]
    if "
        ans.append(w)
for k in range(len(ans[0])):
    print("".join([r[k] for r in ans]))

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

for i in range(H):
    h = list(input())
    matrix.append(h)
    if h == ["."] * W:
        continue
    hd.append(i)

for i in range(W):
    w = [list(w_[i]) for w_ in matrix]
    if w == [["."]] * H:
        continue
    wd.append(i)

ansmatrix = []
row = []
for i in hd:
    for j in wd:
        row.append(matrix[i][j])
    ansmatrix.append(row)
    row = []

for ansrow in ansmatrix:
    print("".join(ansrow))

Solution (Python):
def main():
    H,W = map(int, input().split())
    grid = []
    for i in range(H):
        input_line = str(input())
        if '
            grid.append(input_line)
    

    for j in range(W):
        del_flg = True
        for line in grid:
            if(line[j] == '
                del_flg = False
                break
        if(del_flg):
            for i,line in enumerate(grid):
                line = line[:j] + '0' + line[j+1:]
                grid[i] = line
    
    for line in grid:
            print(line.replace('0',''))
    


if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np
 
H, W=map(int, input().split())
matrix=np.zeros((H, W))
 
for i in range(H):
  s=input()
  for j in range(W):
    if s[j]=='
      matrix[i, j]=1
      
for i in range(H):
  if np.sum(matrix[i, :]==0)==W:
    matrix[i, :]=-1
    
for i in range(W):
  if np.sum(matrix[:, i]<=0)==H:
    matrix[:, i]=-1
    
i=0
for i in range(H):
  if np.sum(matrix[i, :]==-1)==W:
    pass
  else:
    for j in range(W):
      if matrix[i, j]==0:
        print('.', end='')
      elif matrix[i, j]==1:
        print('
      else:
        pass
    print()

Solution (Python):
h,w = map(int,input().split())
src = [input() for _ in range(h)]
li = []
for i,z in enumerate(src[0]):
    if z == '.':
        li.append(i)
eliminate_column_index = []
for l in li:
    tmp = True
    for s in src:
        if s[l] == '
            tmp = False
            break
    if tmp == True:
        eliminate_column_index.append(l)
eliminate_row_index = []
for si,sr in enumerate(src):
    if sr == '.'*w:
        eliminate_row_index.append(si)
for s_row,ss in enumerate(src):
    if s_row in eliminate_row_index:
        continue
    tmp = ''
    for i,s in enumerate(ss):
        if i not in eliminate_column_index:
            tmp += s
    if tmp != '':
        print(tmp)

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


def main():
    H, W = map(int, input().split())
    A = [list(input()[:-1]) for _ in range(H)]

    B = [False]*H
    C = [False]*W
    for i in range(H):
        for j in range(W):
            if A[i][j]=="
                B[i] = True
                C[j] = True
    
    ans = ""
    for i in range(H):
        if B[i]==False:
            continue
        for j in range(W):
            if C[j]==False:
                continue
            ans += A[i][j]
        ans += "\n"

    print(ans[:-1])

if __name__ == '__main__':
    main()

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


def main():
    H, W = map(int, input().split())
    A = [list(input()[:-1]) for _ in range(H)]

    B = [0]*H
    C = [0]*W
    for i in range(H):
        for j in range(W):
            if A[i][j]==".":
                B[i] += 1
                C[j] += 1
    
    ans = ""
    for i in range(H):
        if B[i]==W:
            continue
        for j in range(W):
            if C[j]==H:
                continue
            ans += A[i][j]
        ans += "\n"

    print(ans[:-1])

if __name__ == '__main__':
    main()

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

Solution (Python):
h,w = map(int,input().split())
a = [list(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())
li,li2 = [],[]
for i in range(h):
    a = list(input())
    if "
        li.append(a)
for i in range(len(li)):
    for j in range(w):
        if li[i][j] == ".":
            li[i][j] = 0
        elif li[i][j] == "
            li[i][j] = 1

li = list(zip(*li))
for i in range(len(li)):
    if 1 in li[i]:
        li2.append(li[i])
li2 = list(zip(*li2))
for i in range(len(li2)):
    li2[i] = list(li2[i])
for i in range(len(li2)):
    for j in range(len(li2[i])):
        if li2[i][j] == 0:
            li2[i][j] = "."
        elif li2[i][j] == 1:
            li2[i][j] = "
for i in range(len(li2)):
    print("".join(li2[i]))

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

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

Solution (Python):
h,w=map(int,input().split())
a=[list(input())for _ in range(h)]
b=[]
for i in range(h):
    if a[i].count('.')==w:
        continue
    else:
        b.append(a[i])
c=[]
for i in range(w):
    d=[]
    for j in range(len(b)):
        d.append(b[j][i])
    c.append(d)
e=[]
for i in range(w):
    if c[i].count('.')==len(b):
        continue
    else:
        e.append(c[i])
for i in range(len(b)):
    for j in range(len(e)):
        print(e[j][i],end='')
    print()

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

cntH = 0
for i in range(H-1, -1, -1):
    flag = True
    for j in range(W):
        if a[i][j] == '
            flag = False
            break
    if flag:
        a.pop(i)
        cntH+=1

for j in range(W-1, -1, -1):
    flag = True
    for i in range(H-cntH):
        if a[i][j] == '
            flag = False
    if(flag):
        for i in range(H-cntH):
            a[i].pop(j)

for i in range(H-cntH):
    for j in range(len(a[i])):
        print(a[i][j], end='')
    print('')

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

flagh = [0]*h
flagw = [0]*w

for i in range(0,h):
    if a[i]=="."*w:
        flagh[i] = 1
    for j in range(0,w):
        if a[i][j] == ".":
            flagw[j] += 1

for i in range(h):
    if flagh[i] != 1:
        for j in range(w):
            if flagw[j] != h:
                print(a[i][j],end="")
        print("")

Solution (Python):
h,w=map(int,input().split())
a=list(list(input()) for _ in range(h))
for i in range(h):
    for j in range(w):
        if a[i][j]=='.': a[i][j]=0
        elif a[i][j]=='
for i in range(h):
    if sum(a[i])==0: a[i]=[]
a=[x for x in a if x]
h=len(a)
b=[row for row in zip(*a)]
for i in range(w):
    if sum(b[i])==0: b[i]=[]
b=[x for x in b if x]
w=len(b)
a=[list(row) for row in zip(*b)]
for i in range(h):
    for j in range(w):
        if a[i][j]==0: a[i][j]='.'
        elif a[i][j]==1: a[i][j]='
for row in a: print(''.join(row))

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

tate, yoko = [], []
for i in range(h):
  if any([s == '
    tate.append(i)
for i in range(w):
  if any(a[j][i] == '
    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())
row_list = []
[row_list.append(input()) for h in range(H)]

col_list = []
for w in range(W):
    col = ''
    for h in range(H):
        col += row_list[h][w]
    col_list.append(col)


romit_index_list = [rindex for rindex, r in enumerate(row_list) if r == '.' * W]
comit_index_list = [cindex for cindex, c in enumerate(col_list) if c == '.' * H]

matrix = ''
for h in range(H):
    if h in romit_index_list:
        pass
    else:
        for w in range(W):
            if w in comit_index_list:
                pass
            else:
                matrix += row_list[h][w]


result = [matrix[n: n + W - len(comit_index_list)]
          for n in range(0, len(matrix), W - len(comit_index_list))]


ans = '\n'.join(result)
print(ans)

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):
a, b = map(int, input().split())
L = [input() for _ in range(a)]
L1 = []
L3 = []
for i in range(a):
  if not L[i] == "."*b:
    L1.append(L[i])
L2 = list(map(list, zip(*L1)))
for k in range(len(L2)):
  if not "".join(L2[k]) == "."*len(L2[k]):
    L3.append("".join(L2[k]))
L4 = list(map(list, zip(*L3)))
for v in range(len(L4)):
  print("".join(L4[v]))

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    h, w = map(int, input().split())
    table = [[i == "
    table = list(filter(lambda x: sum(x), table))
    table = [[row[i] for row in table] for i in range(w)]
    table = list(filter(lambda x: sum(x), table))
    table = [[row[i] for row in table] for i in range(len(table[0]))]
    for row in table:
        print("".join(["


if __name__ == "__main__":
    main()

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

a = []

for y in range(h):
    a.append([_ for _ in input()])

rem_x = []
rem_y = []

for y in range(h):
    fl = 0
    for x in range(w):
        if a[y][x] == '
            fl = 1
    if fl == 1:
        rem_y.append(y)

for x in range(w):
    fl = 0
    for y in range(h):
        if a[y][x] == '
            fl = 1
    if fl == 1:
        rem_x.append(x)

for y in rem_y:
    for x in rem_x:
        print(a[y][x],end='')
    print()

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

for x in a:
    if "
        b.append(x)

bT = list(zip(*b))

for x in bT:
    if "
        c.append(x)

cT = list(zip(*c))
for i in cT:
    print("".join(i))

Solution (Python):
H,W = map(int,input().split())
a = [list(input()) for _ in range(H)]
while ["." for _ in range(W)] in a:
    a.remove(["." for _ in range(W)])
c = []
for l in range(len(a[0])):
    s = 0
    for i in range(len(a)):
        if a[i][l] == ".":
            s += 1
    if s == len(a):
        c.append(l)
for i in range(len(a)):
    t = 0
    for l in c:
        del a[i][l-t]
        t += 1
for i in range(len(a)):
    print("".join(a[i]))

Solution (Python):
H,W=map(int,input().split())
A=[]
for h in range(H):
    A.append(list(map(str,input().split())))
A = [a for a in A if "
del_l=[]
for w in range(W):
    s="".join([a[0][w] for a in A])
    if "
        del_l.append(w)
for a in A:
    for w in range(W):
        if w not in del_l:
            print(a[0][w],end="")
    print()

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

for _ in range(H):
    Data.append(input())

hdata = set()
wdata = set()

for h in range(H):
    for w in range(W):
        if Data[h][w] == '
            hdata.add(h)
            wdata.add(w)

for h in range(H):
    output = False
    for w in range(W):
        if h in hdata and w in wdata:
            print(Data[h][w],end='')
            output = True
    if output:
        print('')

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

tbl = str.maketrans({'.':'0','
for _ in range(H):
    s = input().translate(tbl)
    s = list(map(int,list(s)))
    if sum(s) > 0:
        Data1.append(s)

dellist = []
for w in range(W):
    flag = False
    for data in Data1:
        if data[w] == 1:
            flag = True
            break
    if flag == False:
        dellist.append(w)

for i in range(len(dellist)-1,-1,-1):
    for data in Data1:
        data.pop(dellist[i])

for data in Data1:
    for i in range(len(data)):
        if data[i] == 0:
            print('.',end='')
        else:
            print('
    print("")

Solution (Python):
h, w = map(int, input().split())
m = [list(input()) for _ in range(h)]
mr = [r for r in m if '
mrc = [c for c in zip(*mr) if '
print(*(''.join(row) for row in zip(*mrc)), sep='\n')

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

row_idx = []
for idx, row in enumerate(m):
    if not row.count('
        row_idx.append(idx)

col_idx = []
for idx, col in enumerate(zip(*m)):
    if not col.count('
        col_idx.append(idx)

for i, row in enumerate(m):
    if i in row_idx:
        continue
    else:
        for idx in col_idx[::-1]:
            row.pop(idx)
        print(*row, sep='')

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

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

i = 0
while i < H:
    for j in range(W):
        if a[i][j] != '.':
            break
    else:
        a.pop(i)
        H -= 1
        continue
    i += 1

i = 0
while i < W:
    for j in range(H):
        if a[j][i] != '.':
            break
    else:
        for k in range(H):
            a[k].pop(i)
        W -= 1
        continue
    i += 1

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

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

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

l1=[i for i in a if '
l2=[i for i in zip(*l1) if '
for i in zip(*l2):
    print(''.join(i))

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

l1=[]
for i in a:
    if '
        l1.append(i)
l2=[]
for i in zip(*l1):
    if '
        l2.append(i)
l3=zip(*l2)
for i in l3:
    print(''.join(i))

Solution (Python):
h,w=map(int,input().split())
a=[list(input()) for i in range(h)]
for i in range(h):
    if '
        a[i]=['n']*w
for i in range(w):
    l=[a[j][i] for j in range(len(a))]
    if '
        for k in range(len(a)):
           a[k][i]='n'
for i in a:
    l=[x for x in i if x!='n']
    if l:
        print(''.join(l))

Solution (Python):
h,w = map(int, input().split())
row = [False]*h
line = [False]*w
a = []
for i in range(h):
    A = input()
    a.append(A)

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

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

Solution (Python):
h,w = map(int, input().split())
a = [list(x for x in input()) for _ in range(h)]
b = []
c = []
for i in range(h):
  if '
    continue
  else:
    b.append(i)

for j in range(w):
  for k in range(h):
    if '
      break
    elif k == h-1:
      c.append(j)

for m in range(h):
  count = 0
  if m in b:
    continue
  for n in range(w):
    if n in c:
      continue
    else:
      count +=1
      print(a[m][n], end='')
    if count == (w-len(c)):
      print()

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

ls = [list(input()) for i in range(h)]
ls1 = [i for i in ls if '
ls2 = [i for i in zip(*ls1) if '
ls3 = [i for i in zip(*ls2)]

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

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

Solution (Python):
H, W = map(int, input().split())
lst = []
for i in range(H):
    lst.append(list(input()))
for i in range(H-1, -1, -1):
    if '
        del lst[i]
for j in range(W-1, -1, -1):
    cnt = 0
    for i in range(len(lst)):
        if lst[i][j] == '
            cnt += 1
    if cnt == 0:
        for i in range(len(lst)):
            del lst[i][j]
for i in lst:
    print(''.join(i))

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

aLen = w

for j in range(w):
    aSum = sum(aList[i][w - j - 1] == "." for i in range(h))
    if aSum == h:
        for a in range(h):
            aList[a] = aList[a][0:w - j - 1] + aList[a][w - j:aLen]
        aLen -= 1


for i in range(h):
    print(aList[i])

Solution (Python):
h,w = map(int,input().split())
a=["" for _ in range(h)]
for i in range(h):
    a[i]=list(input())
for i in range(h):
    key=0
    for j in range(w):
        if a[i][j]=="
            key=1
    if key==0:
        for j in range(w):
            a[i][j]=""
for i in range(w):
    key=0
    for j in range(h):
        if a[j][i]=="
            key=1
    if key==0:
        for j in range(h):
            a[j][i]=""
for i in range(h):
    if a[i]!=["" for _ in range(w)]:
        print(''.join(a[i]))

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

for i in range(H-1,-1,-1):
    ind = 0
    for j in range(W):
        if A[i][j]!=".":
            ind = 1
            break
    if ind==0:
        A.pop(i)
for j in range(len(A[0])-1,-1,-1):
    ind = 0
    for i in range(len(A)):
        if A[i][j]!=".":
            ind = 1
            break
    if ind==0:
        for i in range(len(A)):
            A[i].pop(j)
for i in range(len(A)):
    x = ""
    for j in range(len(A[i])):
        x += str(A[i][j])
    print(x)

Solution (Python):
h, w = map(int, input().split())
grid = [list(input()) for _ in range(h)]
for _ in range(2):
    grid = list(filter(lambda x: '
    grid = [list(x) for x in zip(*grid)]
for i in range(len(grid)):
    print(''.join(grid[i]))

Solution (Python):

h, w = map(int, input().split())

grid = [list(input()) for _ in range(h)]

for _ in range(2):
    grid = list(filter(lambda x: any(map(lambda x1: x1 == '
    grid = [list(x) for x in zip(*grid)]

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

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

row = []
col = []
for y in range(h):
    cnt = 0
    for x in range(w):
        if mat[y][x] == ".":
            cnt += 1
    if cnt == w:
        row.append(y)

for x in range(w):
    cnt = 0
    for y in range(h):
        if mat[y][x] == ".":
            cnt += 1
    if cnt == h:
        col.append(x)

for y in range(h):
    tmp = ""
    for x in range(w):
        if x not in col and y not in row:
            tmp += mat[y][x]
    if tmp != "":
        print(tmp)

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

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

rm_list = []
for i in range(W):
    candidate = [grid_compred[jth][i] for jth in range(len(grid_compred))]
    if ''.join(candidate) == "." * len(grid_compred):
        rm_list.append(i)

for i in range(len(grid_compred)):
    row_list = [grid_compred[i][j] for j in range(len(grid_compred[i])) if j not in rm_list]
    print(''.join(row_list))

Solution (Python):
from sys import stdout

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

h = [all(c == '.' for c in a[i]) for i in range(H)]

w = [True] * W
for i in range(H):
  for j in range(W):
    w[j] = w[j] and a[i][j] == '.'

for i in range(H):
  if h[i]:
    continue
  for j in range(W):
    if w[j]:
      continue
    stdout.write(a[i][j])
  stdout.write('\n')

Solution (Python):
rows, cols = map(int, input().split())
mat = [input() for _ in range(rows)]

print_row = [False for _ in range(rows)]
print_col = [False for _ in range(cols)]

for i in range(rows):
  for j in range(cols):
    if mat[i][j] == '
      print_row[i] = True
      print_col[j] = True

for i in range(rows):
  print_newline = False
  for j in range(cols):
    if print_row[i] and print_col[j]:
      print(mat[i][j], end="")
      print_newline = True
  if print_newline:
    print()

Solution (Python):
H,W = [int(x) for x in input().split()]
ans = []
for i in range(H):
  cnt= 0
  S = list(input())
  for j in range(W):
    if S[j]==".":
      cnt +=1
  if cnt!=W:
    ans.append(S)
ans1 = []
for j in range(len(ans[0])):
  cnt = 0
  for i in range(len(ans)):
    if ans[i][j]==".":
      cnt+=1
  if cnt ==len(ans):
    ans1.append(j)
for i in range(len(ans)):
  for j in ans1:
    ans[i][j]=0
for i in range(len(ans)):
  for j in range(len(ans[0])):
    if ans[i][j] !=0:
    	print(ans[i][j],end="")
  print()

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

    def rotate_clockwise(matrix):
        return list(map(list, zip(*matrix)))[::-1]

    def rotate_counterclockwise(matrix):
        return list(map(lambda x: list(x[::-1]), zip(*matrix)))

    def remove_white_line(matrix):
        return [row for row in matrix if row.count('.') < len(row)]

    ans = rotate_counterclockwise(remove_white_line(rotate_clockwise(remove_white_line(A))))
    return '\n'.join([''.join(row) for row in ans])

print(b_grid_compression())

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

box_t=[[] for _ in range(len(box_y))]
for i in range(w):
    if any(["
        for j in range(len(box_y)):
            box_t[j].append(box_y[j][i])

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

Solution (Python):
H, W = map(int, input().split())
a_list = [list(input()) for _ in range(H)]
dot_cnt = [sum([a == '.' for a in a_col]) for a_col in a_list]
exist_idx = [i for i, num in enumerate(dot_cnt) if num != W]

st = set(range(W))

for i in exist_idx:
    dot_idx = [i for i, a in enumerate(a_list[i]) if a == '.']
    st = st & set(dot_idx)

for i in exist_idx:
    print(''.join([a for i, a in enumerate(a_list[i]) if i not in st]))

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

pic = [""] * h
for i in range(h):
  pic[i] = input()

row = [False] * h
col = [False] * w
for i in range(h):
  for j in range(w):
    if pic[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(pic[i][j], end = "")
    print()

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

Solution (Python):
H,W = map(int,input().split())
A = [list(input()) for h in range(H)]
A1 = [a for a in A if '
A2 = [a for a in zip(*A1) if '
A3 = [a for a in zip(*A2)]
for a in A3:
    print(''.join(a))