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 = [int(n) for n in input().split()]

matrix = []

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

white = ['.'] * W

pop_list = []
counter = 0

i = H - 1
while i >= 0:
  if matrix[i] == white:
    matrix.pop(i)
    counter += 1
  i -= 1

white = ['.'] * (H - counter)
i = W - 1
 
while i >= 0:
  current_col = [r[i] for r in matrix]
  if current_col == white:
    for j, r in enumerate(matrix):
      matrix[j].pop(i)
  i -= 1

for r in matrix:
  for rr in r:
    print(rr, end = '')
  print('\n')

Solution (Python):
h,w=map(int,input().split())
l=[]
for i in range(h):
  l.append(input())
a=[]
for i in range(h):
  if list(set(l[i]))!=list('.'):
    a.append(l[i])
for i in range(w):
  c=True
  for j in range(len(a)):
    if a[j][i]=='
      c=False
  if c:
    for j in range(len(a)):
      a[j]=a[j][:i]+'a'+a[j][i+1:]
    w-=1
for i in range(len(a)):
  a[i]=a[i].replace('a','')
for i in range(len(a)):
  print(a[i])

Solution (Python):
def main():
    H, W = map(int, input().split())
    a = [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] is True:
            for j in range(W):
                if col[j] is True:
                    print(a[i][j], end='')
            print()


main()

Solution (Python):
h, w = map(int, input().split())
a = []
for i in range(h):
    A = list(map(str,input().split()))
    a.append(A)
kesu = []
for i in range(h):
    b = str(a[i])
    ten = 0
    for l in range(w):
        if b[l+2] == ".":
           ten += 1
    if w == ten :
        kesu.append(i)
for i in range(len(kesu)):
    K = int(kesu[i])
    a.pop(K-i)
hi = []
for i in range(w):
    hkari = ""
    for l in range(len(a)):
        h = str(a[l])
        hz = str(h[i+2])
        hkari += str(hz)
    hi.append(hkari)
kesu = []
for i in range(len(hi)):
    b = str(hi[i])
    ten = 0
    for l in range(len(b)):
        if b[l] == ".":
            ten += 1
    if len(b) == ten:
        kesu.append(i)
for i in range(len(kesu)):
    K = int(kesu[i])
    hi.pop(K-i)
b = len(str(hi[0]))
ans = []
for i in range(b):
    hkari = ""
    for l in range(len(hi)):
        h = str(hi[l])
        hz = str(h[i])
        hkari += str(hz)
    ans.append(hkari)
for i  in range(len(ans)):
    print(ans[i])

Solution (Python):


def main():
    na = list(map(int, input().split()))
    H, W = na[0], na[1]

    a = []
    for i in range(H):
        s = input()
        if '
            a.append(s)

    b = [0] * W
    for s in a:
        for i in range(W):
            if s[i] == '
                b[i] = 1

    for s in a:
        ss = ''
        for i in range(W):
            if b[i] == 1:
                ss += s[i]
        print(ss)


if __name__ == '__main__':
    main()

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


for _ in range(H):
    s=input()
    l=[]
    for x in s:
        l.append(x)
    for x in l:
        if x == ".":
            pass
        else:
            L.append(l)
            break
delete=[]
cou=0
for i in range(W):
    cnt = 0
    for j in range(len(L)):
        if L[j][i]  == '.':
            cnt += 1
        else:
            cnt = 0
    if cnt == len(L):
        delete.append(i-cou)
        cou+=1
for i in delete:
    for j in range(len(L)):
        del L[j][i]

for x in L:
    for y in x:
        print(y,end="")
    print()

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

white = [0]*W
board = []
for _ in [0]*H:
    line = input().rstrip()
    for i in range(W):
        if line[i] == '.': white[i] += 1
    if '
        board.append(list(line))

for line in board:
    for i in range(W):
        if white[i] == H: continue
        else: print(line[i], end='')
    print()

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

a = [list(input()) for i in range(H)]
b = ['.']*W

while b in a:
    a.remove(b)

for j in range(W):
    flag = 0
    for i in a:
        if i[j] == '
            flag = 1
            break
    if flag == 0:
        for i in a:
            i[j] = ''
    
for i in a:
    print(''.join(i))

Solution (Python):
H,W = map(int,input().split())
s = [input() for _ in range(H)]
h = []
w = []
for i in range(H):
    if '
        h.append(i)

for i in range(W):
    ok = True
    for j in range(H):
        if s[j][i] == "
            ok = False
    if ok: w.append(i)
for i in range(H):
    if i in h: continue
    for j in range(W):
        if j not in w:
            print(s[i][j],end="")
    print()

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

    cddt = []
    omission_line = 0
    for i in range(h):
        line = input()
        if line == "." * w:
            omission_line += 1
        else:
            cells = list(line)
            for n, c in enumerate(cells):
                if c == ".":
                    cddt.append(n)
            board.append(cells)

    for line in board:
        for i, c in enumerate(line):
            if (cddt.count(i) + omission_line) != h:
                print(c, end="")
        print("")


if __name__ == '__main__':
    main()

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

for i in range(h):
    A = list(input())
    if  '
        ans.append(A)
        
count = [0] * w
for i in range(len(ans)):
    for j in range(w):
        if ans[i][j] == '.':
            count[j] += 1

num = len(ans)
for i in range(num):
    for j in range(w - 1, -1, -1):
        if count[j] == num:
            del ans[i][j]
        
for i in range(len(ans)):
    print(''.join(ans[i]))

Solution (Python):
import numpy as np

h, w = [int(x) for x in input().split()]
board = [input() for i in range(h)]
dellist = []
for i in range(h):
    if '
        dellist.append(i)
for i in sorted(dellist, reverse=True):
    del board[i]

board = [list(x) for x in board]
board_t = np.array(board).T.tolist()
dellist2 = []
for i in range(w):
    if '
        dellist2.append(i)
for i in sorted(dellist2, reverse=True):
    del board_t[i]

board_t_t = np.array(board_t).T

[print(''.join(x)) for x in board_t_t]

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

for i in range(H):
    a[i] = list(map(str, 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):
    i = input()
    if "
        a.append(i)

ans = []
for i in zip(*a):
    if "
        ans.append(i)
for j in zip(*ans):
    print(*j,sep = "")

Solution (Python):
import numpy as np
h,w=list(map(int,input().split()))
n=[list(input())for i in range(h)]
s=np.array(n)
s=s.T
s=s.tolist()
s=[t for t in s if t!=["."]*h]
k=len(s)
p=np.array(s)
p=p.T
p=p.tolist()
p=[t for t in p if t!=["."]*k]
for i in range(len(p)):
    h=p[i]
    d=len(h)
    c=""
    for j in range(d):
        c+=h[j]
    print(c)

Solution (Python):
H, W = map(int, input().split())
a = []
for _ in range(H):
    i = list(input())
    if '
        a.append(i)
ans = zip(*[i for i in zip(*a) if '
for s in ans:
    print(*s, sep='')

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

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=[]
for x in a:
    if "
c=[]
for y in zip(*b):
    if "
for a in zip(*c):print("".join(a))

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

Solution (Python):
H, W = map(int, input().split())
A = [input() for _ in range(H)]
A = list(filter(lambda a: any(x == "
A = list(filter(lambda a: any(x == "

for a in zip(*A):
    print("".join(a))

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

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

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

Solution (Python):
import numpy as np


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

B = A[:, np.any(A == '
C = B[np.any(B == '

for i in range(C.shape[0]):
    print(''.join(C[i]))

Solution (Python):
H, W = map(int, input().split())
hmax = H
board = []
for _ in range(H):
	line = list(input().rstrip())
	if '
		board.append(line)
	else: hmax -= 1

cnt = [0] * W
for line in board:
	for w, px in enumerate(line):
		if px == '.': cnt[w] += 1

for line in board:
	for w, px in enumerate(line):
		if cnt[w] == hmax: continue
		else: print(px, end='')
	print()

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

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

ans_H = []
for i in range(H):
    if "
        ans_H.append(i)

ans_W = []
for i in range(W):
    cnt = 0
    for j in range(H):
        if LL[j][i] == "
            cnt = 1
    if cnt == 1:
        ans_W.append(i)


for i in ans_H:
    for j in ans_W:
        print(LL[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 = [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()

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

ans = 0
'''
for i in A:
    print(A.index)
    if(i.count('.') == w):
        del A[A.index(i)]   
'''
B = []
for i in range(h):
    if(A[i].count('.') != w):
        B.append(A[i])


count=0
ans=0
for i in range(w):
    i -=ans
    for j in B:
        if(j[i] == '.'):
            count+=1
    if(count==len(B)):
        for j in B:
            del j[i]
        ans +=1
    count=0

for i in B:
    for j in i:
        print(j, end="")
    print()

Solution (Python):
H, W = map(int, input().split())
A = list()
for i in range(H):
	A.append(input())
for i in range(H):
	okrow = False
	for k in range(W):
		if A[i][k] == '
			okrow = True
	if okrow:
		for j in range(W):
			okcol = False
			for k in range(H):
				if A[k][j] == '
					okcol = True
			if okcol:
				print(A[i][j], end = '')
		print()

Solution (Python):
h,w = map(int,input().split())
a = list()
for i in range(h):
    s = input()
    if s != '.'*w:
        a.append(s)
n = len(a)
k = 0
while k < w:
    if all(a[i][k] == '.' for i in range(n)):
        for j in range(n):
            a[j] = a[j][:k] + a[j][k+1:]
        w -= 1
    else:
        k += 1
for i in range(n):
    print(a[i])

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

for i in range(W):
    for j in range(H):
        if A[j][i] == '.':
            count += 1
    if count == H:
        l.append(i)
    count = 0
l.sort(reverse = True)
for k in range(H):
    for m in l:
        A[k] = A[k][:m] + A[k][m + 1:]






B = [i for i in A if i != '.'*len(A[0])]

for _ in range(len(B)):
    print(B[_])

Solution (Python):
def str_del(string,index):
    string = string[:index]+string[index+1:]
    return string




H,W=map(int,input().split())
lines=[]
for i in range(H):
    get=input()
    flag=True
    for s in get:
        if s=='
            flag=False
            break
    if not flag:
        lines.append(get)
    else:
        H-=1


i=0
while(i<W):
    same_flag = True

    for s in range(len(lines)):
        
        if(lines[s][i]=='
                same_flag=False
                break


    if same_flag:
        for s in range(len(lines)):
            lines[s]=str_del(lines[s],i)

        i-=1
        W-=1
            
        

    i+=1


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

Solution (Python):
H, W = map(int, input().split())
a = [input() for _ in range(H)]
skiph = []
skipw = []
for i in range(H):
    if a[i].count('.') == len(a[i]):
        skiph.append(i)
for i in range(W):
    if a[0][i] == '.':
        for j in range(H):
            if a[j][i] == '
                break
        else:
            skipw.append(i)
for i in range(H):
    if i in skiph:
        continue
    for j in range(W):
        if j in skipw:
            continue
        print(a[i][j], end="")
    else:
        print()

Solution (Python):
import numpy as np

a1, a2 = map(int, input().split())
mx = [[list(i) for i in input().split()] for i in range(a1)]
mx = np.reshape(mx,-1)
mx = [0 if i == '.' else 1 for i in mx]
mx = np.reshape(mx,[a1,a2])

w = min(np.append(sum(mx,1),sum(mx,0)))

while w == 0:
    mx = mx[np.sum(mx,1) > 0]
    mx = mx.T[np.sum(mx.T,1) > 0].T
    w = min(np.append(sum(mx,1),sum(mx,0)))

res = np.where(mx == 0 ,".","

for x in res:
    print(''.join(x))

Solution (Python):
H, W = list(map(int, input().split()))
a = []
h = []
w = []
aa = ''

for i in range(H):
    a_ = input()
    aa += a_
    a.append(a_)
    if '
        h.append(i)

for i in range(W):
    if '
        w.append(i)
        
for i in range(H):
    if i not in h:
        continue
    flag = False
    for l in range(W):
        if l in w:
            print(a[i][l], end='')
            flag = True
    if flag == True:
        print('')

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

a1 = []
for h in range(H):
  if not all(s=="." for s in a[h]):
    a1.append(a[h])

a2 = [[] for i in range(len(a1))]
for w in range(W):
  tmp_a = [row[w] for row in a1]
  if not all(s=="." for s in tmp_a):
    for i in range(len(tmp_a)):
      a2[i].append(tmp_a[i])

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

Solution (Python):
t = input().split(" ")
H = int(t[0])
W = int(t[1])
list1 = []
for i in range(H):
    t = str(input())
    list1.append(t)
erase_index = []
for i in range(H):
    W_count = 0
    for j in range(W):
        if list1[i][j] == '.':
            W_count += 1
    if W_count == W:
        erase_index.append(i)
erase_char = []
for i in range(W):
    H_count = 0
    for j in range(H):
        if list1[j][i] == '.':
            H_count += 1
    if H_count == H:
        erase_char.append(i)
for i in range(len(erase_index)):
    list1.pop(erase_index[len(erase_index)-1-i])
ans = []
for i in zip(*list1):
    ans.append(list(i))
for i in range(len(erase_char)):
    ans.pop(erase_char[len(erase_char)-1-i])
answer = []
for i in zip(*ans):
    answer.append(list(i))
for i in range(len(answer)):
    s = ""
    for j in range(len(answer[i])):
        s += str(answer[i][j])
    print(s)

Solution (Python):
H, W = map(int, input().split())
a = []
for _ in range(H):
    i = list(input())
    if '
        a.append(i)
ans = zip(*[i for i in zip(*a) if '
for s in ans:
    print(*s, sep='')

Solution (Python):
coord = []


def compress_y():
    global coord
    for y in range(len(coord)):
        if all(c == '.' for c in coord[y]):
            coord = coord[:y] + coord[y + 1:]
            return True
    return False


def compress_x():
    global coord
    for x in range(0, len(coord[0])):
        if all(row[x] == '.' for row in coord):
            for y in range(len(coord)):
                coord[y] = coord[y][:x] + coord[y][x + 1:]
            return True
    return False


def main():
    global coord
    h, w = map(int, input().split())
    coord = [list(input()) for _ in range(h)]
    while compress_y():
        pass
    while compress_x():
        pass

    for row in coord:
        print(''.join(row))


if __name__ == '__main__':
    main()

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

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

row = []
column = []

for i in range(H):
    flag = True
    for j in range(W):
        if a[i][j] != '.':
            flag = False
            break
    if flag:
        row.append(i)

for j in range(W):
    flag = True
    for i in range(H):
        if a[i][j] != '.':
            flag = False
            break
    if flag:
        column.append(j)

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

Solution (Python):
a,b = map(int,input().split(" "))
ar = []
br = [[] for i in range(b)]
for i in range(a):
    l = list(input())
    if "
        ar.append(l)
    for j in range(b):
        br[j].append(l[j])
cr = []
for i,r in enumerate(br):
    if "
        cr.append(i)
er = [[] for i in range(len(ar))]
for i in range(len(ar)):
    for j in range(b):
        if j not in cr:
            er[i].append(ar[i][j])
for r in er:
    print("".join(r))

Solution (Python):
height, width = (int(x) for x in input().split())
matrix = []

for i in range(height):
  matrix.append(input())

row = [0] * width
column = [0] * height

for i in range(height):
  if '
    column[i] = 1
    for j in range(width):
      if (matrix[i][j] == '
        row[j] = 1

for i in range(height):
  if (column[i] == 1):
    for j in range(width):
      if (row[j] == 1):
        print(matrix[i][j], end = '')
    print()

Solution (Python):
import numpy as np
h, w = map(int, input().split())

field = [list(input()) for x in range(h)]
for i, row in list(enumerate(field))[::-1]:
    if "
        del field[i]

field = list(np.transpose(field))
for i, row in list(enumerate(field))[::-1]:
    if "
        del field[i]

for i in np.transpose(field):
    print("".join(i))

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

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

for i in reversed(range(len(a))):
  if '
    del a[i]

a = list(zip(*a))
for i in reversed(range(len(a))):
  if '
    del a[i]

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

Solution (Python):
import numpy as np
H, W = list(map(int, input().split()))

a = np.array([list(input()) for i in range(H)])

at = np.all(a == '.', axis = 1)
for i in reversed(range(len(at))):
  if at[i]:
    a = np.delete(a, i, 0)

at = np.all(a == '.', axis = 0)
for i in reversed(range(len(at))):
  if at[i]:
    a = np.delete(a, i, 1)
for i in a:
  print(''.join(i))

Solution (Python):
H,W = map(int,input().split())
A = []
for _ in range(H):
    a = list(input())
    if '
        A.append(a)
    else:
        H -= 1

for i in range(W-1,-1,-1):
    ch = 0
    for j in range(H):
        if A[j][i] == '
            ch = 0
            break
        else:
            ch = 1
    if ch == 1:
        for k in range(H):
            del A[k][i]
    
for a in A:
    print(''.join(a))

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

for i in range(H):
    list = [i for i in input()]
    if list.count("
        HWlist.append(list)
    for j in range(W):
        if list[j] == "
            w.append(j)
    
for i in range(len(HWlist[0])-1,-1,-1):
    if i not in w:
        for j in HWlist:
            del j[i]

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

Solution (Python):
import numpy as np
N,M=map(int,input().split())
x=[]
for n in range(N):
	x.append(list(input()))

for __ in range(2):
	check=[]
	count=0
	for _ in range(len(x[0])):
		check.append(".")
	for xi in x:
		if xi == check:
			count+=1
	for _ in range(count):
		x.remove(check)
	x=np.array(x).T.tolist()

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

Solution (Python):
h, w = map(int, input().split())
hlist = []
wlist = []
a = [list(input()) for i in range(h)]
for i in range(h):
    for j in range(w):
        if a[i][j] == "
            hlist.append(i)
            wlist.append(j)
for i in set(hlist):
    for j in set(wlist):
        print(a[i][j], end ="")
    print()

Solution (Python):
h,w = map(int, input().split())
p = [input() for _ in range(h)]
p = [row for row in p if not all(map(lambda i: i == ".", row))]
p = [col for col in zip(*p) if not all(map(lambda i: i == ".", col))]
for row in zip(*p):
    print("".join(row))

Solution (Python):
H, W = map(int, input().split())
t = []
for _ in range(H):
    x = input()
    if x != '.' * W:
        t += [x]
num = len(t)
k = []
for s in zip(*t):
    s = ''.join(s)
    if s != '.' * num:
        k += [s]
for x in zip(*k):
    print(''.join(x))

Solution (Python):
H, W = map(int, raw_input().split())
a = []
for i in range(H):
  a.append(raw_input())
b = [r for r in a if "
c = ["".join(r) for r in zip(*b) if "
for l in zip(*c):
  print "".join(l)

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

grid = []
for i in range(h):
    row = str(input())

    for j in range(w):
        if row[j] == "
            grid.append(row)
            break

cls = []
for i in range(w):
    count = 0

    for j in range(len(grid)):    

        if grid[j][i] == "." :
            count += 1

    if count >= len(grid) :
        cls.append(i)

for i in range(len(grid)):
    for j in range(w) :
        if j not in cls:
            print(grid[i][j],end="")
    print()

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

tate = [False]*h
yoko = [False]*w

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

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

Solution (Python):
import numpy as np

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

list1 =[input() for i in range(h)]


list2=[]
for i in range(h):
  if list1[i].count('
    list2.append(list1[i])

list2_num=len(list2)

list4=[]
for i in range(list2_num):
  list3=(list(list2[i]))
  list4.append(list3)

list4=np.array(list4).T


list4=list4.tolist()
list5=[]
for i in range(w):
  if list4[i].count('
    list5.append(list4[i])


list5=np.array(list5).T

list5=list5.tolist()

for i in range(len(list5)):
  for j in range(len(list5[0])):
    print(list5[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):
f=lambda s:zip(*[t for t in s if'
for r in f(f(__import__('sys').stdin)):print(*r,sep='')

Solution (Python):
h,w = map(int, input().split())
d = []
for i in range(h):
    d.append(input())
row = [False] * h
col = [False] * w
for i in range(h):
    for j in range(w):
        if d[i][j] == '
            row[i] = True
            col[j] = True
for i in range(h):
    if row[i]:
        s = ""
        for j in range(w):
            if col[j]:
                s += d[i][j]
        if len(s) > 0:
            print(s)

Solution (Python):
H,W=map(int,input().split())
M=[0]*H
for i in range(H):
    M[i]=input()
H_cnt=[0]*H
W_cnt=[0]*W
for i in range(H):
    for j in range(W):
        if M[i][j]=='
            H_cnt[i]=1
            W_cnt[j]=1
for i in range(H):
    for j in range(W):
        if W_cnt[j]==1 and H_cnt[i]==1:
            print(M[i][j],end='')
    if H_cnt[i]==1:
        print()

Solution (Python):
a,b=map(int,input().split())

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

d=['.'for i in range(b)]

e=[]
for i in range(a):
	if c[i]!=d:
		e.append(c[i])


f=[]
for i in zip(*e):
	f.append(list(i))


g=['.'for i in range(len(e))]

h=[]
for i in range(len(f)):
	if f[i]!=g:
		h.append(f[i])

j=[]
for i in zip(*h):
	j.append(list(i))
for i in range(len(j)):
	print(''.join(j[i]))

Solution (Python):
h,w = map(int,input().split())
a = [input() for _ in range(h)]
b = []
for i in range(h):
    if a[i] != '.'*w:
        b.append(a[i])
ans = []
for i in range(w):
    flag = False
    for j in range(len(b)):
        flag |= b[j][i]=='
    if not flag:
        ans.append(i)
for i in b:
    for j,k in enumerate(i):
        if j not in ans:
            print(k,end='')
    print('')

Solution (Python):

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

A = []

for i in range(H):
    a = list(input())  
    if '
        A.append(a)
    else:
        H = H - 1

for i in range(W - 1, -1, -1):  
    ch = 0
    for j in range(H):
        if A[j][i] == '
            ch = 0
            break
        else:
            ch = 1
    if ch == 1:
        for k in range(H):
            del A[k][i]

for i, a in enumerate(A):
    print(''.join(a))

Solution (Python):
import numpy as np
WH='.'
BK='
x=input()
x=x.split()
H=int(x[0])
W=int(x[1])
a=[[] for i in range(H)]
num=[]
numnum=0
for i in range(H):
    x=input()
    for j in range(W):
        a[i].append(x[j])
for i in range(H):
    flag=0
    for j in range(W):
        if a[i][j]==WH:
            flag=flag+1
        else:
            flag=flag-1
    if flag==W:
        num.append(i)
        numnum=numnum+1
for i in range(numnum):
    a.pop(num[i]-i)
H=H-numnum
a_n=np.array(a)
tr=a_n.T
a=tr.tolist()
num=[]
numnum=0
num_num=0
for i in range(W):
    flag=0
    for j in range(H):
        if a[i][j]==WH:
            flag=flag+1
        else:
            flag=flag-1
    if flag==H:
        num.append(i)
        numnum=numnum+1
        flag=0
    else:
        flag=0
for i in range(numnum):
    a.pop(num[i]-i)
W=W-numnum
a_n=np.array(a)
a=a_n.T
for i in range(H):
    ans=''
    for j in range(W):
        ans=ans+a[i][j]
    print(ans)

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

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

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

Solution (Python):
H,W = map(int,input().split())
A = []
for i in range(H):
    a = list(input())
    if "
        A.append(a)
    else:
        H -= 1
for j in range(W-1,-1,-1):
    for i in range(H):
        if A[i][j] == "
            break
        elif i == H - 1:
            for k in range(H):
                del A[k][j]
for e in A:
    print("".join(e))

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

for y in range(H) :
    for x in range(W) :
        if L[y][x] == "
            X[x] = True
            Y[y] = True

for y in range(H) :
    if Y[y] == True :
        ANS = []
        for x in range(W) :
            if X[x] == True :
                ANS.append(L[y][x])
        print("".join(ANS))

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

row = []
column = []

for i in range(h):
    flag = 1
    first = "."
    for j in range(w):
        if a[i][j] != first:
            flag = 0
    if flag == 0:
        row.append(i)

for j in range(w):
    flag = 1
    first = "."
    for i in range(h):
        if a[i][j] != first:
            flag = 0
    if flag == 0:
        column.append(j)


for i in row:
    output = ""
    for j in column:
        output += a[i][j]
    if output != "":
        print(output)

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

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

h,w = li()
grid = [lc() for _ in range(h)]
new_h = []
new_w = []

for hi in range(h):
    if "
        new_h.append(hi)

for wj in range(w):
    for hi in range(h):    
        if "
            new_w.append(wj)
            break
        
ans = [["" for _ in range(len(new_w))] for _ in range(len(new_h))]

for i,nhi in enumerate(new_h):
    for j,nwj in enumerate(new_w):
        ans[i][j] = grid[nhi][nwj]
        
for row in ans:
    print("".join(row))

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

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

h,w = li()
grid = [lc() for _ in range(h)]
new_h = []
new_w = []

for hi in range(h):
    if "
        new_h.append(hi)

for wj in range(w):
    for hi in range(h):    
        if "
            new_w.append(wj)
            break
        
ans = [["" for _ in range(len(new_w))] for _ in range(len(new_h))]

for i,nhi in enumerate(new_h):
    for j,nwj in enumerate(new_w):
        ans[i][j] = grid[nhi][nwj]
        
for row in ans:
    print("".join(row))