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 = [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):
X,Y = map(int,input().split())
whole = []
for i in range(X):
  now = input()
  if now == '.' * Y:
    pass
  else:
    add = []
    for i in range(Y):
      if now[i] == '.':
        add.append(0)
      else:
        add.append(1)
    whole.append(add)
j = 0
while j < len(whole[0]):
  for i in range(len(whole)):
    if whole[i][j] == 1:
      j += 1
      break
  else:
    for i in range(len(whole)):
      del whole[i][j]
for i in range(len(whole)):
  now = whole[i]
  ans = ''
  for j in range(len(now)):
    if now[j] == 0:
      ans += '.'
    else:
      ans += '
  print(ans)

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

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

ans = []
for i in range(W):
	row = [j[i] for j in lst]
	if ("".join(row) != "." * H):
		ans.append("".join(row))

for i in range(H):
	row = [j[i] for j in ans]
	if ("".join(row) != "." * len(row)):
		print("".join(row))

Solution (Python):
A=[]
h,w=map(int,input().split())
for i in range(h):
	s=input()
	if s.count("
		A.append(s)
B=[]
C=[]
for i in range(w):
	cnt=0
	for j in range(len(A)):
		if A[j][i]==".":
			cnt+=1
	if cnt==len(A):
		B.append(i)
for i in range(w):
	c=""
	for j in range(len(A)):
		if i not in B:
			c+=A[j][i]
	if len(c)>0:
		C.append(c)
for j in range(len(C[0])):
	p=""
	for i in range(len(C)):
		p+=C[i][j]
	print(p)

Solution (Python):
from functools import reduce
import math

def main():
    
    
    
    

    
    
    
    
    
    

    
    

    
    
    
    
    
    
    
    
    
    INF = float("inf")

    
    MOD = 10**9+7
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    H, W = (int(_) for _ in input().split())
    a = []
    for i in range(H):
        a.append(list(_ for _ in input()))
    a_1 = []
    for i in range(H):
        if a[i].count('.') != W:
            a_1.append(a[i])
    W_bit = list(1 for _ in range(W))
    for h in range(len(a_1)):
        for w in range(W):
            if a_1[h][w] == '
                W_bit[w] = 0    

    for h in range(len(a_1)):
        for w in range(W):
            if W_bit[w] == 0:
                print(a_1[h][w],end='')
        print('')
if __name__ == '__main__':
    main()

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 = [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())

C = []

for i in range(H):
    temp = input()

    for i in temp:
        if i != '.':
            C.append(temp)
            break

WB = [0] * W

for i in range(len(C)):
    for j in range(W):
        if C[i][j] == '.':
            WB[j] += 1

for i in range(len(C)):
    for j in range(W):
        if WB[j] != len(C):
            print(C[i][j], end='')
    print()

Solution (Python):
H, W = list(map(int,input().split(' ')))
ar = []
for i in range(H):
  w = list(input())
  
  if set(w) != {'.'}:
    ar.append(w)
    


import numpy as np
ar2 = np.array(ar)
ar2_T = ar2.T
ar = []
for i in ar2_T:

  if set(i) != {'.'}:
    ar.append(i)

ar_T = np.array(ar).T
for i in ar_T:
  print(''.join(i))

Solution (Python):
import sys

input = sys.stdin.readline
h, w = map(int, input().split())


f = lambda s: zip(*[column for column in s if '
L = [input() for _ in range(h)]

for row in f(f(L)):
    print(*row, sep='', end='\n')

Solution (Python):
h,w = map(int, input().split())
li = []
for i in range(h):
    a = list(input())
    '''
    if all([a[i] == "." for i in range(w)]):
        continue
    else:
        li.append(a)
    '''
    if "
      li.append(a)
for j in range(w):
    
    if all(li[k][j] == "." for k in range(len(li))):
        for k in range(len(li)):
            
            li[k][j] = ""
for m in range(len(li)):
    print("".join(li[m]))

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

for j in range(w):
  if all(l[k][j] == "." for k in range(len(l))):
    for k in range(len(l)):
      l[k][j] = ""
for m in range(len(l)):
  print(''.join(l[m]))

Solution (Python):
def row(A):
  B = []
  for a in A:
    if "
      B.append(a)
  return B

def trans(A):
  c = len(A[0])
  B = []
  for i in range(c):
    C = ""
    for j in range(len(A)):
      C += A[j][i]
    B.append(C)
  return B

def col(A):
  return trans(row(trans(A)))
        
      

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

while col(A) != A or row(A) != A:
  A = col(A)
  A = row(A)

for i in A:
  print(i)

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

a = [x for x in a if "
aT = list(zip(*a))
aT = [x for x in aT if "
a = list(zip(*aT))

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

Solution (Python):
h,w = map(int,input().split())
l = []
for i in range(h):
  x = list(input())
  if "
    l.append(x)
for j in range(w):
  if all(l[i][j] == "." for i in range(len(l))):
    for i in range(len(l)):
      l[i][j] = ""
for i in range(len(l)):
  print(''.join(l[i]))

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

t = [i for i in zip(*b)]
c = zip(*[i for i in t if "
for d in c:
    print("".join(d))

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

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

for i in range(H):
    if "
        for j in range(i, H):
            L[i] = [None] * W
            
for i in range(W):
    f = True
    for j in range(H):
        if L[j][i] == "
            f = False
            break
    if f:
        for j in range(H):
            L[j][i] = None
            
for i in range(H):
    f = False
    for j in range(W):
        if L[i][j] != None:
            print(L[i][j], end = "")
            f = True
    if f:
        print()

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


row_change = 1
col_change = 1
while(row_change == 1 or col_change == 1):
    row_change = 0
    col_change = 0
    row_del = []
    col_del = []

    for i in range(A.shape[0]):
        if all([a == '.' for a in A[i,:]]):
            row_del.append(i)
            row_change = 1
    A = np.delete(A, row_del, 0)

    for j in range(A.shape[1]):
        if all([a == '.' for a in A[:,j]]):
            col_del.append(j)
            col_change = 1
    A = np.delete(A, col_del, 1)

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

Solution (Python):
H,W = map(int,input().split())
t = []
for i in range(H):
    x = list(input())
    if "
        t.append(x)
for i in range(W):
    if all((t[j][i] == "." for j in range(len(t)))):
        for k in range(len(t)):
            t[k][i] = ""
for i in range(len(t)):
    print("".join(t[i]))

Solution (Python):
h, w = map(int, input().split())
a = []
for i in range(h):
    a.append(list(input()))
for i in range(h - 1, -1, -1):
    if a[i] == ["."] * w:
        del a[i]
for i in range(w - 1, -1, -1):
    if [a[j][i] for j in range(len(a))] == ["."] * len(a):
        for j in range(len(a)):
            del a[j][i]
for i in range(len(a)):
    print("".join(a[i]))

Solution (Python):
h, w = map(int, input().split())
a = [input() for _ in range(h)]
blank_h, blank_w = set(), set()
for i in range(h):
    count = 0
    for j in range(w):
        if a[i][j] != '.':
            break
        count += 1
    if count == w:
        blank_h.add(i)
for j in range(w):
    count = 0
    for i in range(h):
        if a[i][j] != '.':
            break
        count += 1
    if count == h:
        blank_w.add(j)
for i in range(h):
    if i in blank_h:
        continue
    for j in range(w):
        if j in blank_w:
            continue
        print(a[i][j], end='')
    print()

Solution (Python):
import numpy as np
h, w = list(map(int, input().split()))
loc_array = [list(input().replace("
loc_array = np.array([list(map(int, l)) for l in loc_array])
row_sum = loc_array.sum(axis=1)
col_sum = loc_array.sum(axis=0)
while 0 in row_sum or 0 in col_sum:
  row_rm = [i for i, r in enumerate(row_sum) if r == 0]
  loc_array = np.delete(loc_array, row_rm, axis=0)
  col_rm = [i for i, c in enumerate(col_sum) if c == 0]
  loc_array = np.delete(loc_array, col_rm, axis=1)
  row_sum = loc_array.sum(axis=1)
  col_sum = loc_array.sum(axis=0)

loc_str = [list(map(str, loc_array[i,:])) for i in range(loc_array.shape[0])]
loc_str = ["".join(l).replace("1", "
for l in loc_str:
  print(l)

Solution (Python):
import numpy as np
m = []
h, w = map(int, input().split())
for i in range(h):
    arr = list(input())
    if '
        m.append(arr)
    else:
        pass
m = np.array(m).T.tolist()
output = []
for i in range(w):
    if '
        output.append(m[i])
    else:
        pass
output = np.array(output).T.tolist()
for i in range(len(output)):
    print(''.join(output[i]))

Solution (Python):
def removewhite(l):
  return [item for item in l if all([c=="." for c in item])==False]

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

a=np.array(removewhite(np.array(removewhite(a)).T.tolist()
                      )
          ).T.tolist()
[print("".join(l)) for l in a]

Solution (Python):
l = [int(i) for i in input().split(" ")]
h = l[0]
w = l[1]
m = []

def trans(matrix):
    t_matrix = []
    h = len(matrix)
    w = len(matrix[0])
    for i in range(w):
        row = []
        for j in range(h):
            row.append(matrix[j][i])
        t_matrix.append(row)
    return t_matrix

def remove_dot(matrix):
    new_matrix = []
    for row in matrix:
        if "
            pass
        else:
            new_matrix.append(row)
    return new_matrix

for i in range(h):
    m.append(list(input()))
for i in range(2):
    m = remove_dot(m)
    m = trans(m)
for row in m:
    print("".join(row))

Solution (Python):
l = [int(i) for i in input().split(" ")]
h = l[0]
w = l[1]

m = []
m_t = []
m_tt = []

for i in range(h):
    row = list(input())
    if "
        pass
    else:
        m.append(row)


for i in range(w):
    row = []
    for j in range(len(m)):
        row.append(m[j][i])
    if "
        pass
    else:
        m_t.append(row)


for i in range(len(m)):
    row = []
    for j in range(len(m_t)):
        row.append(m_t[j][i])
    m_tt.append(row)

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

Solution (Python):
N, M = map(int, input().split())
a = [0] * N
for i in range(N):
    a[i] = list(input())

del_N = []
del_M = []

for i in range(N):
    if a[i].count('.') == M :
        del_N.append(i)

for i in range(M):
    tmp = []
    for j in range(N):
        tmp.append(a[j][i])
    if tmp.count('.') == N:
        del_M.append(i)



ans1 = []
for i in range(N):
    if i not in del_N:
        ans1.append(a[i])



ans2 = [[] for _ in range(len(ans1))]
for i in range(len(ans1)):
    for j in range(M):
        if j not in del_M:
            ans2[i].append(str(ans1[i][j]))



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

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

table = [[] for _ in range(h)]
skiph = []
skipw = []
for i in range(h):
    table[i] = list(input())
    if len(set(table[i])) == 1:
        if table[i][0] == ".":
            skiph.append(i)

for i in range(w):
    if table[0][i] == ".":
        for j in range(h):
            if table[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
        else:
            print(table[i][j], end="")
    print()

Solution (Python):

def rem(a):
    res = []
    for x in a:
        if x.count('
            res.append(x)
    return res

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

while a != rem(a):
    a = rem(a)


a = list(zip(*rem(list(zip(*a)))))

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

Solution (Python):
y, x = map(int, input().split())
r = [True] * y
c = [True] * x
z = []
for i in range(y):
    a = input()
    z.append(a)
    for j in range(x):
        if '
            c[j] = False
            r[i] = False
for i in range(y):
    if r[i] == False:
        for j in range(x):
            if c[j] == False:
                print(z[i][j], end='')
        print()

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

l = []
for i in range(w):
    s = ""
    for j in range(len(grid)):
        f = grid[j]
        s = s+f[i]
    if "
        l.append(s)

ans = []
for i in range(len(l[0])):
    s = ""
    for j in range(len(l)):
        f = l[j]
        s = s+f[i]
    ans.append(s)
for i in ans:
    print(i)

Solution (Python):
def main():
    H, W = map(int, input().split())
    A = [[c for c in input()] for _ in range(H)]
    sniprows = set()
    for i in range(H):
        snip = True
        for j in range(W):
            if A[i][j] == "
                snip = False
        if snip:
            sniprows.add(i)
    snipcols = set()
    for j in range(W):
        snip = True
        for i in range(H):
            if A[i][j] == "
                snip = False
        if snip:
            snipcols.add(j)
    for i in range(H):
        if i in sniprows:
            continue
        ans = ""
        for j in range(W):
            if j in snipcols:
                continue
            ans += A[i][j]
        print(ans)


if __name__ == "__main__":
    main()

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

for j in range(W):
    if all([a[j] == '.' for a in A]):
        for i in range(len(A)):
            A[i] = A[i][:j] + '*' + A[i][j + 1:]
for a in A:
    print(a.replace('*', ''))

Solution (Python):

def ch(info,w): 
    c=0
    for i in range(w):
        if info[i]=="
            c=1
            break
    return c

h,w=map(int,input().split())
info=[]
black=[]
hl=0
for i in range(h):
    s=list(input())
    if ch(s,w)==1:
        info.append(s)
        hl+=1

for i in range(hl):
    for j in range(w):
        if info[i][j]=="
            black.append(j)
for i in range(hl):
    for j in range(w):
        if j in black:
            print(info[i][j],end="")
    print("\n")

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

li= np.array([input() for _ in range(h)])
del_count= 0
for i in range(h):
     if li[i-del_count] == "." * w:
         li = np.delete(li, i-del_count, 0)
         del_count+=1

del_count = 0
for i in range(len(li[0])):
    for j in range(len(li)):
        if li[j][i-del_count] == "
            break
        elif j == len(li)-1:
            for k in range (len(li)):
                li[k] = li[k][:i-del_count]+li[k][i-del_count+1:]
            del_count+= 1
for i in li:
    print(i)

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

ans = []
for i in range(h):
    temp = input()
    if '
        continue
    ans.append(temp)

for i in reversed(range(w)):
    if ans[0][i] == '.':
        flag = True
        for j in range(len(ans)):
            if ans[j][i] != '.':
                flag = False
                break

        if flag:
            for j in range(len(ans)):
                ans[j] = ans[j][:i] + (ans[j][i+1:len(ans[j])] if i+1 < len(ans[j]) else '')

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

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

LL=list(zip(*L))

LL=[l for l in LL if "
L=list(zip(*LL))
for l in L:
  print("".join(l))

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

rmh = 0
for h in range(H):
    h -= rmh
    ok = True
    for w in range(W):
        if state[h][w] == '
            ok = False
            break
    if ok:
        state.pop(h)
        rmh += 1
H -= rmh
rmw = 0
for w in range(W):
    w -= rmw
    ok = True
    for h in range(H):
        if state[h][w] == '
            ok = False
            break
    if ok:
        for h in range(H):
            state[h].pop(w)
        rmw += 1

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

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

aLst = [list(map(str, input().split())) for i in range(H)]

deIndex = []
for i in range(H):
    if aLst[i][0].count('.') == W:
        deIndex.append(i)
deIndex.sort(reverse=True)

for i in deIndex:
    del aLst[i]
H -= len(deIndex)
deIndex.clear()

for i in range(W):
    kCnt = 0
    for j in range(H):
        if aLst[j][0][i] == '.':
            kCnt += 1

    if kCnt == H:
        deIndex.append(i)
if len(deIndex) == 0:

    for i in range(H):
        print(''.join(aLst[i]))
else:
    deIndex.sort(reverse=True)
    tmplist = [['' for i in range(W)] for j in range(H)]
    for j in range(H):
        tmplist[j] = list(aLst[j][0])

    for i in range(H):
        for j in deIndex:
            del tmplist[i][j]

    W -= len(deIndex)
    for i in range(H):
        print(''.join(tmplist[i]))

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    n, i = LI()
    print(n-i+1)
    return


def B():
    h, w = LI()
    a = SR(h)
    dy = defaultdict(int)
    dx = defaultdict(int)
    for y in range(h):
        for x in range(w):
            if a[y][x] == "
                dx[x] = 1
                dy[y] = 1
    dy = list(sorted(dy.items(), key=lambda x: x[0]))
    dx = list(sorted(dx.items(), key=lambda x: x[0]))
    for y,_ in dy:
        for x,_ in dx:
            print(a[y][x], end="")
        print()


    return


def C():
    return


def D():
    return


if __name__ == '__main__':
    B()

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

p = ['.']*W
while p in L:
    L.remove(p)
    H -= 1

L2 = [[0]*H for _ in range(W)]
for h in range(H):
    for w in range(W):
        L2[w][h] = L[h][w]


q = ['.']*H
while q in L2:
    L2.remove(q)
    W -= 1

ans = [[0]*W for _ in range(H)]
for h in range(H):
    for w in range(W):
        print(L2[w][h], end="")
    print()

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

L = []
R = []

for i in range(H):
  R_cnt = 0
  for j in range(W):
    if A[i][j] == '.':
      R_cnt += 1
  if R_cnt == W:
    R.append(i)

for j in range(W):
  L_cnt = 0
  for i in range(H):
    if A[i][j] == '.':
      L_cnt += 1
  if L_cnt == H:
    L.append(j)

for i in range(H):
  S = []
  for j in range(W):
    if i in R:
      break
    elif j in L:
      continue
    else:
      S.append(A[i][j])
  if len(S) > 0:
    print(''.join(S))

Solution (Python):
H,W = map(int, input().split())
List = []
for i in range(H):
    List.append([a for a in input()])
i = 0
j = 0
while i < len(List):
    if List[i].count("
        del List[i]
        i -= 1
    i += 1

while j < len(List[0]):
    c = 0
    for k in range(len(List)):
        if List[k][j] == ".":
            c += 1
    if c == len(List):
        for k in range(len(List)):
            List[k] = List[k][:j] + List[k][j+1:]
        j -= 1
    j += 1

for l in range(len(List)):
    print("".join(List[l]))

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

cnt = 0
while True:
  flag = True
  for i in range(H):
    tmp = 0
    vis = 0
    for j in range(W):
      if vissible[i][j]:
        vis += 1
      if vissible[i][j] and grid[i][j] == '.':
        tmp += 1
    if vis and tmp == vis:
      for j in range(W):
        vissible[i][j] = False
      flag = False
  for j in range(W):
    tmp = 0
    vis = 0
    for i in range(H):
      if vissible[i][j]:
        vis += 1
      if vissible[i][j] and grid[i][j] == '.':
        tmp += 1
    if vis and tmp == vis:
      for i in range(H):
        vissible[i][j] = False
      flag = False
  if flag:
    break
  if cnt > 10:
    break
  cnt += 1
for i in range(H):
  flag = False
  for j in range(W):
    if vissible[i][j]:
      print(grid[i][j], end='')
      flag = True
  if flag:
    print()

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

for _ in range(H):
    a = list(input())
    if a.count('.') == W:
        a = len(a) * ['!']
    lines.append(a)

for w in range(W):
    c = True
    for h in range(H):
        if lines[h][w] == '
            c = False
            break
    if c:
        for h in range(H):
            lines[h][w] = '!'

for l in lines:
    if l.count('!') == W:
        continue
    for c in l:
        print('' if c == '!' else c, end='')
    print()

Solution (Python):
H, W = map(int, input().split())
field = []
for i in range(0, H):
	S = input()
	lst = []
	for j in range(0, W):
		lst.append(S[j])
	if '
		field.append(lst)
for i in range(0, W):
	flag = True
	for j in range(0, len(field)):
		if field[j][i] == '
			flag = False
			break
	if flag:
		for j in range(0, len(field)):
			field[j][i] = ''
for i in range(0, len(field)):
	ans = ''
	for j in range(0, W):
		ans = ans + field[i][j]
	print(ans)

Solution (Python):
r,c=map(int,input().split())
mat=[list(input()) for i in range(r)]

r_chk=[0]*r
c_chk=[0]*c

for i in range(r):
	for j in range(c):
		if mat[i][j]=='
			r_chk[i]=1
			c_chk[j]=1

for i in range(r):
	chk=0
	for j in range(c):
		if r_chk[i]==1 and c_chk[j]==1:     
			print(mat[i][j],end='')
			chk=1
	if chk==1:
		print('')

Solution (Python):
h,w = map(int,input().split())
li = []
for i in range(h):
    a = list(input())
    li.append(a)
li2 = li.copy()
c = 0
for i in range(h):
    for j in range(w):
        c = 0
        if li[i][j] == ".":
            continue
        elif li[i][j] == "
            c = 1
            break
    if c == 0:
        li[i] = ["a"] * w
d = 0
n = []
for i in range(w):
    for j in range(h):
        d = 0
        if li[j][i] == "." or li[j][i] == "a":
            continue
        else:
            d = 1
            break
    if d == 0:
        n.append(i)
for i in n:
    for j in range(h):
        li[j][i] = "a"

for i in range(h):
    grid = ""
    for x in li[i]:
        if x != "a":
            grid += x
    if grid != "":
        print(grid)

Solution (Python):
a, b = map(int, input().split())
e = []
f = [True] * b
for i in range(a):
    c = list(input())
    d = True
    for j in range(b):
        if c[j] == "
            d = not d
        if c[j] == "
            f[j] = not f[j]
    if not d:
        e.append(c)
for i in range(len(e)):
    g = ""
    for j in range(b):
        if not f[j]:
            g += e[i][j]
    print(g)

Solution (Python):
import numpy as np

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

board = np.array([list(input()) for i in range(h)])

t_h = []
t_w = []
for i in range(h):
    if np.count_nonzero(board[i] == ".") != w:
        t_h.append(i)
for i in range(w):
    if np.count_nonzero(board[:,i] == ".") != h:
        t_w.append(i)

for y in t_h:
    for x in t_w:
        print(board[y][x],end="")
    print()

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

WHITE='.'
print_row=[]
print_col=[]
for i in range(H):
    for j in range(W):
        if a[i][j] != WHITE:
            if i not in print_row:
                print_row.append(i)
            if j not in print_col:
                print_col.append(j)

for i in range(H):
    linefeed = False
    for j in range(W):
        if i in print_row and j in print_col:
            linefeed = True
            print(a[i][j], sep="", end="")
    if linefeed:
        print(sep="")

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

rr = []
for i in range(h):
    c = Counter(a[i]).most_common()
    if len(c) > 1 or c[0][0] == '
        rr.append(i)

rc = []
for i in range(w):
    c = Counter([x[i] for x in a]).most_common()
    if len(c) > 1 or c[0][0] == '
        rc.append(i)

a = '\n'.join(''.join(a[j][i] for i in rc) for j in rr)
print(a)

Solution (Python):
a,b=map(int,input().split())
cc=[input() for i in range(a)]
c=[[""for i in range(b)]for j in range(a)]
for i in range(a):
  for j in range(b):
    c[i][j]=cc[i][j]
d=[]
e=0
for i in range(a):
  e=0
  for j in range(b):
    if c[i][j]=="
      e=1
  if e==0:
    d.append(i)
for i in d:
  c.pop(i)
  for j in range(len(d)):
    d[j]=d[j]-1
d=[]
for i in range(b):
  e=0
  for j in range(len(c)):
    if c[j][i]=="
      e=1
  if e==0:
    d.append(i)
for i in d:
  for j in range(len(c)):
    c[j].pop(i)
  for j in range(len(d)):
    d[j]=d[j]-1

for i in range(len(c)):
  g=""
  for j in range(len(c[i])):
    g+=c[i][j]
  print(g)

Solution (Python):
import sys
import numpy as np
h,w = map(int,input().split())
a = [input() for i in range(h)]
a = [list(map(int,list(a[i].replace("

aa = np.array(a)

tate = np.sum(aa,axis=0)
yoko = np.sum(aa,axis=1)

for i in range(len(tate)-1,-1,-1):
  if tate[i] == 0:
    aa = np.delete(aa,i,1)

for i in range(len(yoko)-1,-1,-1):
  if yoko[i] == 0:
    aa = np.delete(aa,i,0)

aa = np.where(aa == 0, ".", aa)
aa = np.where(aa == '1', "

a = aa.tolist()

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

Solution (Python):
h, w = map(int, input().split())
g = []
ans = []
for _ in range(h):
    s = [c for c in input()]
    g.append(s)
del_col = []
for j in range(w):
    col = [r[j] for r in g]
    if all([x == '.' for x in col]) :
        del_col.append(j)
del_col.sort(reverse=True)

for i in range(h):
    if not all([x == '.' for x in g[i]]):
        for d in del_col:
            g[i].pop(d)
        ans.append(g[i])
for r in ans:
    print(''.join(r))

Solution (Python):
h,w = map(int,input().split())
A = [list(input()) for i in range(h)]
AH = []
AW = []
for i in range(h):
    if '
        AH.append(i)
for j in range(w):
    flag = 0
    for i in range(h):
        if A[i][j]=='
            flag = 1
    if flag:
        AW.append(j)
for i in AH:
    res = []
    for j in AW:
        res.append(A[i][j])
    print("".join(res))

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

for i in range(h-1, -1, -1):
    s = list(input())
    if s!=["."]*w:
        l.append(s)

for j in range(w-1, -1, -1):
    cnt = 0
    for k in range(len(l)):
        if l[k][j]==".":
            cnt += 1
    if cnt ==len(l):
        for k in range(len(l)):
            l[k].pop(j)

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

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

ans=[]

for i in range(h):
    if "
        ans.append(l[i])
        
for i in range(w):
    if all([ans[j][i]=="." for j in range(len(ans))]):
        for k in range(len(ans)):
            ans[k]=list(ans[k])
            ans[k][i]=""

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

Solution (Python):
H,W=map(int, input().split())
s=[]
for _ in range(H):
    s.append(list(input()))
x = []
y = []
for i in range(len(s)):
    if set(s[i])=={"."}: 
        x.append(i)
for i in range(len(s[0])):
    y_check = []
    for j in range(len(s)):
        y_check.append(s[j][i])
    if set(y_check)=={"."}:
        y.append(i)
for i in x[::-1]:
    del s[i]
for j in range(len(s)):
    for i in y[::-1]:
        del s[j][i]
for i in s:
    for j in i:
        print(j,end="")
    print("")

Solution (Python):
h, w = map(int, input().split())
board = [input() for _ in range(h)]
ansH = [False] * h
ansW = [False] * w
for i in range(h):
    for j in range(w):
        if(board[i][j] == '
            ansH[i] = True
            ansW[j] = True

for i in range(h):
    if(ansH[i] == False):
        continue
    ans = ""
    for j in range(w):
        if(ansW[j]):
            ans += board[i][j]
    print(ans)