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 = []
dame = ["."]*W
for i in range(H):
  temp = str(input())
  temp = list(temp)
  if temp != dame:
    A.append(temp)

S = len(A)
ans = [[] for _ in range(S)]
for j in range(W):
  if all([A[i][j] == "." for i in range(S)]):
    continue
  for t in range(S):
    ans[t].append(A[t][j])

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

Solution (Python):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

h,w=nii()
a=[list(input()) for i in range(h)]

t_ans=[]
for i in a:
  if '
    t_ans.append(i)

t_ans=[i for i in zip(*t_ans)]

ans=[]
for i in t_ans:
  if '
    ans.append(i)

ans=[i for i in zip(*ans)]

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

Solution (Python):
H,W=map(int,input().split())
A=[list(input()) for i in range(H)]
a=0
for i in range(H):
  if set(A[i-a])==set(['.']):
    del A[i-a]
    a+=1
b=0
for i in range(W):
  for j in range(H-a):
    if A[j][i-b]=='
      break
    if j==H-a-1:
      for k in range(H-a):
        del A[k][i-b]
      b+=1
for i in range(len(A)):
  print(''.join(A[i]))

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

ans = ['' for _ in range(len(B))]
for col in zip(*B):
    if all(c=='.' for c in col): continue
    for i,c in enumerate(col):
        ans[i] += c

for row in ans:
    print(row)

Solution (Python):
import sys
import numpy as np

rm = lambda: map(int, sys.stdin.readline().split())
rr = lambda: sys.stdin.readline().rstrip()

h, w = rm()
li = np.array([np.array(list(rr())) for _ in range(h)])
li2 = []
li3 = []
for i in li:
  if '
    li2.append(i)
li2 = np.array(li2).T
for i in li2:
  if '
    li3.append(i)
li3 = np.array(li3).T
for i in li3:
  print(''.join(i))

Solution (Python):
def solve():
    H, W = map(int, input().split())
    row = [False for _ in range(H)]
    column = [False for _ in range(W)]
    a = [['' for _ in range(W)] for _ in range(H)]
    for i in range(H):
        a[i] = input()
        for j in range(W):
            if a[i][j] == '
                row[i] = True
                column[j] = True

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


if __name__ == "__main__":
    solve()

Solution (Python):
import numpy as np
H, W = map(int, input().split())
a = []
for i in range(H):
  s = str(input())
  l = [c for c in s]
  a.append(l)
  
a = np.array(a)
cnt = 0
for i in range(H):
  s = np.array([a[0]])
  a = np.delete(a, 0, 0)
  if '
    a = np.append(a, s, axis=0)
    cnt += 1
    
for i in range(W):
  s = np.array([a[:, 0]]).reshape(cnt, 1)
  a = np.delete(a, 0, 1)
  if '
    a = np.append(a, s, axis=1)

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

Solution (Python):
h, w = map(int, input().split())
b = []
li = [0] * w
for i in range(h):
    a = list(input())
    b.append(a)
    for j in range(w):
        if a[j] == "
            li[j] += 1

for i in range(h):
    if b[i].count(".") == w:
        continue
    for j in range(w):
        if li[j] != 0:
            print(b[i][j], end="")
    print("")

Solution (Python):
from collections import defaultdict
import itertools
import copy

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

def p(arr,b="\n",e="\n"):
  print(b,end="")
  for i in arr:
    for j in i:
      print(j,end="")
    print()
  print(e,end="")

h,w = readInts()
a = [list(input()) for i in range(h)]

for i in range(h-1,-1,-1):
  boo = 1
  for j in range(w-1,-1,-1):
    if a[i][j]=="
      boo = 0
  if boo==1:
    del a[i]

for i in range(len(a[0])-1,-1,-1):
  boo = 1
  for j in range(len(a)-1,-1,-1):
    if a[j][i]=="
      boo = 0
  if boo==1:
    for j in range(len(a)-1,-1,-1):
      del a[j][i]

p(a,b="",e="")

Solution (Python):
import sys
H,W = map(int,input().split())
array_list = []
for I in range(H):
    array_list.append(list(map(str,input())))

if not ( 1 <= H <= 100 and 1 <= W <= 100 ):
    sys.exit()

Horizon_list = []
Vertical_list = []

for J in range(len(array_list)):
    if array_list[J].count('.') == W:
        Horizon_list.append(J)

list_check = [list(x) for x in zip(*array_list)]
for K in range(len(list_check)):
    if list_check[K].count('.') == H:
        Vertical_list.append(K)

for L in range(H):
    for M in range(W):
        if (L not in Horizon_list ) and (M not in Vertical_list):
            print(array_list[L][M],end='')
    print('\n')

Solution (Python):
import sys
H,W = map(int,input().split())
array_list = []
for I in range(H):
    array_list.append(list(map(str,input())))

if not ( 1 <= H <= 100 and 1 <= W <= 100 ):
    sys.exit()



Horizon_list = []
Vertical_list = []

for J in range(len(array_list)):
    if array_list[J].count('.') == W:
        Horizon_list.append(J)

list_check = [list(x) for x in zip(*array_list)]
for K in range(len(list_check)):
    if list_check[K].count('.') == H:
        Vertical_list.append(K)


for L in range(H):
    for M in range(W):
        if (L not in Horizon_list ) and (M not in Vertical_list):
            print(array_list[L][M],end='')
    print('\n')

Solution (Python):




import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools
import copy













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

S = []
for _ in range(H):
    S.append(list(input()))

R = []
C = []

for i in range(H):
    flag = 1
    for j in range(W):
        if S[i][j] == "
            flag = 0
            break
    if flag == 1:
        R.append(i)

for i in range(W):
    flag = 1
    for j in range(H):
        if S[j][i] == "
            flag = 0
            break
    if flag == 1:
        C.append(i)

C.sort(reverse=True)
R.sort(reverse=True)

if len(C)>0:
    for i in range(len(C)):
        for j in range(H):
            del S[j][C[i]]

if len(R)>0:
    for i in range(len(R)):
        del S[R[i]]

for i in range(len(S)):
    for j in range(len(S[i])):
        print(S[i][j], end='')
    print()

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

grid = []
del_cnt = 0
for i in range(h):
    row = input()
    if '
        grid.append(row)
    else:
        del_cnt += 1
ans = []
for i in range(w):
    col = ""
    for j in range(h-del_cnt):
        col += grid[j][i]
    if '
        ans.append(i)

for i in range(h-del_cnt):
    tmp = ""
    for a in ans:
        tmp += grid[i][a]
    print(tmp)

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



while 1:
  h, w = [0, 0]
  hl = []
  for i in range(len(a)):
    w = 0
    for j in range(len(a[0])):
      
      if a[i][j] != '.':
        w += 1
    
        
    if w == 0:
      hl.append(i)
      
  hl.sort(reverse = True)
  for i in hl:
    del a[i]
    
  wl = []
  for i in range(len(a[0])):
    h = 0
    for j in range(len(a)):
      if a[j][i] != '.':
        h += 1
    
        
    if h == 0:
      wl.append(i)
      
  wl.sort(reverse = True)
  for i in wl:
    for j in range(len(a)):
      del a[j][i]
        
  if h != 0 and w != 0:
    break
    
for i in range(len(a)):
  print(''.join(a[i]))

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

row = []
col = []
for i in range(h):
  if a[i].count("
    
for i in range(w):
  for j in range(h):
    if a[j][i] == "
  else: col.append(i)

for i in range(h):
  if i in row: continue
  ans = ""
  for j in range(w):
    if j in col: continue
    ans += a[i][j]
  print(ans)

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

row = [0] * h
column = [0] * w
for i in range(h):
    for j in range(w):
        if field[i][j] == '
            row[i] = 1
            column[j] = 1

for i in range(h):
    if row[i] == 1:
        for j in range(w):
            if column[j] == 1:
                print(field[i][j], end='')
        print()

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

remove_h = []
for i in range(h):
    if set(G[i]) == {"."}:
        remove_h.append(i)

remove_w = []
for j in range(w):
    if set([g[j] for g in G]) == {"."}:
        remove_w.append(j)

for i in range(h):
    if i not in remove_h:
        S = ""
        for j in range(w):
            if j not in remove_w:
                S += G[i][j]
        print(S)

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

for i in range(h):
    ls = list(input())
    if "
        l.append(ls)
        

s = [0]*w

for i in range(len(l)):
  for j in range(w):
    if l[i][j] == "
      s[j] = 1  

for i in range(len(l)):
  ans = ""
  for j in range(w):
    ans += l[i][j]*s[j]
  print(ans)

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

for i in range(h):
    ls = list(input())
    if "
        l.append(ls)
        for j in range(w):
            if ls[j] == "." and j not in r:
                r.append(j)

s = [i for i in range(w)]

for i in r:
  count = 0
  for j in range(len(l)):
    if l[j][i] == ".":
      count += 1
  if count == len(l):
    s.remove(i) 

ans = []
for i in range(len(l)):
  a = []
  for j in s:
    a.append(l[i][j])
  ans.append(a)
  

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

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

row=[]
col=[]

for i in range(h):
    flg=0
    for j in range(w):
        if grid[i][j]=='
            flg=1

    if flg==0:
        row.append(i)


for j in range(w):
    flg=0
    for i in range(h):
        if grid[i][j]=='
            flg=1

    if flg==0:
        col.append(j)

ans=[]
for i in range(h):
    arr=[]
    for j in range(w):
        if i in row or j in col:
            continue
        else:
            arr.append(grid[i][j])
    if len(arr)!=0:
        ans.append(arr)

for k in ans:
    t=''.join(k)
    print(t)

Solution (Python):
def main():
    h,w=map(int,input().split())
    a = [list(input()) for _ in range(h)]
    b = []
    for i in a:
        if i.count(".") != w:
            b.append(i)
    for i in list(range(w))[::-1]:
        for j in b:
            if j[i] == "
                break
        else:
            for j in range(len(b)):
                del b[j][i]
    for x in b:
        print("".join(x))

if __name__ == "__main__":
    main()

Solution (Python):
h,w = map(int,input().split())
a = [input() for _ in range(h)]
tmp = []
flag = True
for i in range(h):
    for j in range(w):
        if a[i][j] == '
            flag = False
    if flag:
        tmp.append(i)
    flag = True
flag = True
tmp2 = []
for i in range(w):
    for j in range(h):
        if a[j][i] == '
            flag = False
    if flag:
        tmp2.append(i)
    flag = True
t = set(tmp)
t2 = set(tmp2)
for i in range(h):
    for j in range(w):
        if i not in t and j not in t2:
            print(a[i][j],end='')
    if i not in t:
        print()

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

b = []
for i in range(h):
    if "
        b.append(a[i])


c = [list(x) for x in zip(*b)]
ans = []
for i in range(len(c)):
    if "
        ans.append(c[i])
        
ans = [list(x) for x in zip(*ans)]
for v in ans:
    print("".join(v))

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    H, W = LI()
    a = [SS() for _ in range(H)]

    white_columun = set()
    for c in range(W):
        cnt = 0
        for r in range(H):
            if a[r][c] == '.':
                cnt += 1
        if cnt == H:
            white_columun.add(c)

    for i in a:
        if i.count('.') < W:
            ans = []
            for j in range(W):
                if not j in white_columun:
                    ans.append(i[j])
            print(''.join(ans))

if __name__ == '__main__':
    resolve()

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

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

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

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

Solution (Python):
h, w = map(int, input().split())
lst = []
alldot = [True] * w
for i in range(h):
  s = input()
  if s.count('
    lst.append(s)
    for t in range(w):
      alldot[t] = alldot[t] and s[t] == '.'
  else:
    h -= 1
res = [''] * h
for i in range(h):
  for j in range(w):
    if alldot[j]:
      pass
    else:
      res[i] += lst[i][j]
for i in res:
  print(i)

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

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

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

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

Solution (Python):
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


h, w = LI()
a = [list(S()) for _ in range(h)]
ans = [[a[j][i] for i in range(w)] for j in range(h)]



for i in range(h):
    is_white = True
    for j in range(w):
        if a[i][j] == '.':
            continue
        else:
            is_white = False
            break
    if is_white:
        ans[i] = [False] * w

for i in range(w):
    is_white = True
    for j in range(h):
        if a[j][i] == '.':
            continue
        else:
            is_white = False
            break
    if is_white:
        for j in range(h):
            
            ans[j][i] = False

for i in range(w):
    is_white = True
    for j in range(h):
        if a[j][i] == '.':
            continue
        else:
            is_white = False
            break
    if is_white:
        for j in range(h):
            
            ans[j][i] = False
res = ''
for i in range(h):
    if not(any(ans[i])):
        continue
    for j in range(w):
        if ans[i][j]:
            res += ans[i][j]
    res += '\n'
print(res.rstrip('\n'))

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

i = 0
while i < H:
    j = 0
    while j < W and A[i][j] == '.':
        j += 1
    if j >= W:
        for k in range(i, H - 1):
            for j in range(W):
                A[k][j] = A[k + 1][j]
        H -= 1
    else:
        i += 1
j = 0
while j < W:
    i = 0
    while i < H and A[i][j] == '.':
        i += 1
    if i >= H:
        for k in range(j, W - 1):
            for i in range(H):
                A[i][k] = A[i][k + 1]
        W -= 1
    else:
        j += 1
for i in range(H):
    for j in range(W):
        print(A[i][j], end='')
    print()

Solution (Python):
import numpy as np
h,w=map(int,input().split())
li=[]
for i in range(h):
  li.append(list(input()))
ll=[]
for i in li:
  if "
    ll.append(i)
ll=np.array(ll).T.tolist()

out=[]
for i in ll:
  if "
    out.append(i)
out=np.array(out).T.tolist()
for i in out:
  for j in i:
    print(j,end="")
  print()

Solution (Python):






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


a = []
for _h in range(h):
    a.append(list(input()))

mask = [[False] * w for h in range(h)]


for i, row in enumerate(a):
    if all([True if c == '.' else False for c in a[i]]):
        mask[i] = [True] * w


x = [True] * w
for row in a:
    for j, col in enumerate(row):
        if col == '.':
            x[j] = x[j] and True
        else:
            x[j] = x[j] and False

for i, row in enumerate(a):
    for j, _x in enumerate(x):
        if _x:
            mask[i][j] = True

for i in range(h):
    if all(mask[i]):
        continue
    p_row = ''.join([a[i][j] for j in range(w) if mask[i][j] is False])
    print(p_row)

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

compress_row = []

for i in range(h):
    if '
        compress_row.append(i)

compress_col = []
for i in range(w):
    for j in range(h):
        if a[j][i] == '
            break
    else:
        compress_col.append(i)

row = []
for i in range(h):
    col = []
    for j in range(w):
        if j in compress_col:
            continue
        col.append(a[i][j])
    if i in compress_row:
        continue
    row.append(col)

print(*[''.join(r) for r in row], sep='\n')

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 h in range(H)]
row = H*[False]
col = W*[False]

for h in range(H):
  for w in range(W):
    if A[h][w]=="
      row[h] = True
      col[w] = True

for h in range(H):
  if row[h]:
    for w in range(W):
      if col[w]:
        print(A[h][w],end="")
    print()

Solution (Python):
H, W = map(int, input().split())
a = []
for i in range(H):
    b = input()
    count = b.count('.')
    if count == W:
        continue
    else:
        a += [list(map(str, b))]

num = len(a)
val = []
for i in range(W):
    for j in range(num):
        if a[j][i] == '.':
            if j == num-1:
                val.append(i)
            else:
                continue
        else:
            break
for i in reversed(val):
    for j in range(num):
        del a[j][i]
for i in range(len(a)):
    print(''.join(a[i]))

Solution (Python):
y,x=map(int,input().split())
lst=[]
for i in range(y):
    lst.append(input())
    
del_line=[]
del_row=[]
for i in range(y):
    cnt=0
    for j in range(x):
        if lst[i][j]==".":
            cnt+=1
    if cnt==x:
        del_line.append(i)
for i in range(x):
    cnt=0
    for j in range(y):
        if lst[j][i]==".":
            cnt+=1
    if cnt==y:
        del_row.append(i)

for i in range(y):
    if not i in del_line:
        pr=[]
        for j in range(x):
            if not j in del_row:
                pr.append(lst[i][j])
        print("".join(pr))

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

removed_rows = []
removed_cols = []
for row in range(1, H+1):
    is_all_dot = 1
    for col in range(1, W+1):
        if a[row][col] == "
            is_all_dot = 0
    if is_all_dot:
        removed_rows.append(row)
for col in range(1, W+1):
    is_all_dot = 1
    for row in range(1, H+1):
        if a[row][col] == "
            is_all_dot = 0
    if is_all_dot:
        removed_cols.append(col)

for row in range(1, H+1):
    if row in removed_rows:
        continue
    for removed_col in removed_cols:
        a[row][removed_col] = ""
    ans = "".join(a[row][1:])
    print(ans)

Solution (Python):

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

rowIndex=[False]*h
colIndex=[False]*w

for i in range(h):
    for j in range(w):
        if a[i][j]=='
            rowIndex[i]=True
            colIndex[j]=True
    
for i in range(h):
    if rowIndex[i]:
        for j in range(w):
            if colIndex[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 i in range(h)])

new_a= np.empty((0,len(a[0])), dtype='<U1')
for i in a:
    if "
        new_a = np.append(new_a, [i], axis=0)
a = new_a.T
new_a= np.empty((0,len(a[0])), dtype='<U1')
for i in a:
    if "
        new_a = np.append(new_a, [i], axis=0)
a = new_a.T
for i in a:
    print("".join(i))

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



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



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

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

b = []
for i in range(h):
  if a[i].count('.') != w:
    b.append(a[i])
  else:
    h -= 1

c = [''] * h
for i in range(w):
  x = [row[i] for row in b] 
  if x.count('.') != h:
    for j in range(h):
      c[j] = c[j] + x[j]
    
for i in c:
  print(i)

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

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

for i in range(h):
    s = input()
    if s != "."*w:
        a.append(s)

l = len(a)

ans = [[] for i in range(l)]

for i in range(w):
    for j in range(l):
        if a[j][i] == "
            for k in range(l):
                ans[k].append(a[k][i])
            break
for i in range(l):
    print("".join(ans[i]))

Solution (Python):
H,W=map(int,input().split())
row=[False]*H
col=[False]*W
b=['']*H
for i in range(H):
  a=input()
  b[i]=a
  for j in range(W):
    if a[j]=='
      row[i]=True
      col[j]=True
for i in range(H):
  if row[i]:
    for j in range(W):
      if col[j]:
        if row[i] and col[j]:
          print(b[i][j],end='')
    print()

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

for i in range(H):
    if list(set(a[i])) != ["."]:
        counter.append(list(a[i]))

b = list(zip(*counter))
banswer = []

for i in range(W):
    if list(set(b[i])) != ["."]:
        banswer.append(list(b[i]))

answer = list(zip(*banswer))

for j in answer:
    result = "".join(j)
    print(result)

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):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

H,W = I()
S = []
for i in range(H):
    s1 = list(s())
    if '
        S.append(s1)
L = [1]*W
for i in range(len(S)):
    if 1 not in L:
        break
    for j in range(W):
        if S[i][j] == '
            L[j] = 0
for i in range(W-1,-1,-1):
    if L[i] == 1:
        for j in range(len(S)):
            S[j].pop(i)
for i in range(len(S)):
    print(''.join(S[i]))

Solution (Python):
h,w = map(int, input().split())
a = [list(input()) for _ in range(h)]
dh = []
dw = []
for i in range(h):
  if not('
    dh.append(i)
for j in range(w):
  cal = ''
  for k in range(h):
    cal += a[k][j]
    if k == h-1 and not('
      dw.append(j)

for hl in sorted(dh, reverse=True):
  a.pop(hl)

for wl in sorted(dw, reverse=True):
  for i in range(h-len(dh)):
    a[i].pop(wl)

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

Solution (Python):
h, w = map(int, input().split())
field = []
for i in range(h):
  field.append(list(input()))
tfield = [x for x in zip(*field)]
wh = []
ww = []

for i in range(h):
  if len(set(field[i])) == 1 and field[i][0] == ".":
    wh.append(i)

for i in range(w):
  if len(set(tfield[i])) == 1 and tfield[i][0] == ".":
    ww.append(i)

for i in range(h):
  if i in wh:
    continue
  for j in range(w):
    if j not in ww:
      print(field[i][j], end="")
  print("")

Solution (Python):
if __name__ == '__main__':
    h, w = map(int, input().split())
    map=[]
    for i in range(h):
        a=input()
        map.append(a)
    checkH=[False]*h
    checkW=[False]*w

    for i in range(h):
        for j in range(w):
            if map[i][j] =="
                checkH[i]=True
                checkW[j] = True

    for i in range(h):
        ans=""
        for j in range(w):
            if checkH[i] ==True and checkW[j]==True:
                ans+=map[i][j]
        if ans != "":
            print(ans)

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

l=[]
for i in range(h):
    a=input()
    if "
        l.append(a)


r=[]
for i in range(w):
    for k in l:
        if k[i]=="
            r.append(i)
            break
n=len(l)
new_l=[]

for i in range(n):
    s=""
    for k in r:
        s=s+l[i][k]
    new_l.append(s)

for i in new_l:
    print(i)

Solution (Python):
import numpy as np
n,m=map(int,input().split())
arr=[]
for i in range(n):
    l=[ord(c)-46 for c in input()]
    if l.count(0)==m:
        continue
    arr.append(l)
a=np.array(arr)
a=a.T
b=[]
for i in range(len(a)):
    if list(a[i]).count(0)==len(a[i]):
        continue
    b.append(list(a[i]))
b=list(np.array(b).T)
for l in b:
    for x in l:
        if x==0:
            print(".",end="")
        else:
            print("
    print()

Solution (Python):
import sys
import itertools

import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

A = [0] * H
for i in range(H):
    A[i] = list(input())

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

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

Solution (Python):
import sys
import itertools

import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

A = [0] * H
for i in range(H):
    A[i] = list(input())

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

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

Solution (Python):
import sys
import itertools

import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

A = [0] * H
for i in range(H):
    A[i] = list(input())


x = set()
for i in range(H):
    if all(True if a == '.' else False for a in A[i]):
        x.add(i)

ans = []
for i in range(H):
    if i in x:
        continue
    ans.append(A[i])

A = ans
x = set()
for i in range(W):
    if all(True if A[j][i] == '.' else False for j in range(len(A))):
        x.add(i)

ans = []
for i in range(len(A)):
    z = []
    for j in range(W):
        if j not in x:
            z.append(A[i][j])
    ans.append(z)

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

Solution (Python):
def imp():return map(int,input().split())
h,w=imp()
l=[]
for _ in range(h):
    s=input()
    if '

ans=[]
for j in range(w):
    s=""
    for i in range(len(l)):
        s+=l[i][j]
    if '

w=len(ans[0])
for j in range(w):
    s=""
    for x in ans:
        s+=x[j]
    print(s)

Solution (Python):
from functools import reduce
from decimal import *
from operator import mul

def main():
    h, w = input_list()
    masu = []
    for _ in range(h):
        line = list(input())
        masu.append(line)
    rows = [False] * h
    cols = [False] * w
    for i, m in enumerate(masu):
        for j, v in enumerate(m):
            if v == "
                rows[i] = True
                cols[j] = True
    for i, m in enumerate(masu):
        if rows[i] is False:
            continue
        a = ''
        for j, v in enumerate(m):
            if cols[j] is False:
                continue
            a += v
        print(a)

def count_tento(l, cur):
    count = 0
    for v in l:
        if v > cur:
            count += 1
    return count

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

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

if __name__ == '__main__':
    main()