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):
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction



mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]









n,m=l()
A=[input() for i in range(n)]
r=set()
c=set()
for i in range(n):
    if "
        r.add(i)

for i in range(m):
    x=[A[j][i] for j in range(n)]
    if "
        c.add(i)
for i in range(n):
    if(i not in r):
        continue
    for j in range(m):
        if(j in c):
            print(A[i][j],end="")
    print()

Solution (Python):

import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left 
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

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

res = []
for h in aHW:
    if '
        res.append(h)

res = list(zip(*res))
res2 = []
for h in res:
    if '
        res2.append(h)

res2 = list(zip(*res2))

for h in res2:
    print(''.join(h))

Solution (Python):
H, W = map(int, input().split())
a = [input() for _ in range(H)]
count = 0
while True:
  length = len(a)
  a = [i for i in a if not(len(set(i)) == 1 and i[0] == '.')]
  if len(a) == length:
    break
  a = list(zip(*a))
  count += 1
if count % 2 != 0: a = list(zip(*a))
[print(''.join(i)) for i in list(a)]

Solution (Python):
import numpy as np

h, w = map(int, input().strip().split())
table = np.array([list(input().strip()) for _ in range(h)])


def compress_row(table):
    new_table = []
    compressed = False
    for row in table:
        if all([c == '.' for c in row]):
            compressed = True
            continue
        else:
            new_table.append(row)

    return compressed, np.array(new_table)


def compress_col(table):
    tr_table = table.T
    compressed, new_tr_table = compress_row(tr_table)
    return compressed, new_tr_table.T


while True:
    row_compressed, table = compress_row(table)
    col_compressed, table = compress_col(table)

    if (not row_compressed) and (not col_compressed):
        break

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

Solution (Python):
H, W = map(int, input().split())
field = [input() for _ in range(H)]
comp_rows = []
comp_cols = []
for i in range(H):
    if field[i] == "." * W:
        comp_rows.append(i)
for j in range(W):
    if "".join(field[i][j] for i in range(H)) == "." * H:
        comp_cols.append(j)
for i in range(H):
    if i in comp_rows:
        continue
    print("".join(field[i][j] for j in range(W) if j not in comp_cols))

Solution (Python):
H, W=map(int, input().split())
A=[]
tate=[False]*W
for i in range(H):
  tmp=list(input())
  if "
    continue
  A.append(tmp)
  for j in range(W):
    if tmp[j]=="
      tate[j]=True

for i in range(len(A)):
  ans=[]
  for j in range(W):
    if tate[j]:
      ans.append(A[i][j])
  print("".join(ans))

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

h = len(a)
w = len(a[0])
for i in range(w):
    judge = False
    for j in range(h):
        if a[j][i] == '
            judge = True
    
    if not judge:
        index.append(i)

cnt = 0
for i in index:
    for j in range(h):
        del a[j][i-cnt]
    cnt += 1
for i in a:
    print(''.join(i))

Solution (Python):
h, w = map(int, input().split())
S = [input() for i in range(h)]
A = []
for s in S:
	if '
		A.append(s)
nh = len(A)
B = [''] * nh
for x in range(w):
	if any(a[x] == '
		for y in range(nh):
			B[y] += A[y][x]
for b in B:
	print(b)

Solution (Python):

import numpy as np
H, W  = map(int, input().split())
data = [input().split() for _ in range(int(H))]
data_new = np.empty((0, W))
data_ = []
for i in data:
    for h in i[0]:
        data_.append(h)        
data_ = np.array(data_).reshape(H, W)

for i in data_:
    if np.any(i == "
        data_new = np.concatenate([data_new, i.reshape(1, W)])
        
data_ = data_new.T
data_new = np.empty((0, data_.shape[1]))

for i in data_:
    if np.any(i == "
        data_new = np.concatenate([data_new, i.reshape(1, data_.shape[1])])

data_new = data_new.T

for i in data_new:
    i = i.tolist()
    print(''.join(i))

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

for i in range(H):
    for j in range(W):
        if a[i][j] == '
            a[i][j] = 1
        else:
            a[i][j] = 0

a = np.array(a)

while True:
    flag = True
    for i in range(len(a)-1, -1, -1):
        if sum(a[i]) == 0:
            a = np.delete(a, i, 0)
            flag = False

    a = a.T
    for i in range(len(a)-1, -1, -1):
        if sum(a[i]) == 0:
            a = np.delete(a, i, 0)
            flag = False
    a = a.T

    if flag:
        break

ans = [['
for i in range(len(a)):
    for j in range(len(a[i])):
        if a[i][j] == 0:
            ans[i][j] = '.'

for i in range(len(a)):
    for j in range(len(a[i])):
        print(ans[i][j], end="")
    print()

Solution (Python):
h,w=map(int,input().split())
a2=[]
for i in range(h):
    a=list(input())
    if '
        a2.append(a)
for i in range(w):
    x=[row[i] for row in a2]
    if '
        for j in range(len(a2)):
            a2[j][i]=''
for i in a2:
    print(*i,sep='')

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

d=[]
memo=[0]*W
for i in range(H):
  row=list(str(input()))
  if '
    d.append(row)
  for j in range(W):
    if row[j] == '
      memo[j] = 1

for i in range(len(d)):
  for j in range(W):
    if memo[j] == 1:
      print(d[i][j],end='')
  print()

Solution (Python):
h,w=map(int,input().split())
a=[]
for i in range(h):
  temp=list(map(str,input()))
  a.append(temp)
temph=[]
tempw=[]
for i in range(h):
  for j in range(w):
    if a[i][j]!=".":
      break
  else:
    temph.append(i)
for i in range(w):
  for j in range(h):
    if a[j][i]!=".":
      break
  else:
    tempw.append(i)
import numpy as np
tempnp=np.array(a)
for i in range(len(temph)):
  tempnp=np.delete(tempnp, temph[i]-i, 0)
for i in range(len(tempw)):
  tempnp=np.delete(tempnp, tempw[i]-i, 1)
for i in range(h-len(temph)):
  print("".join(tempnp[i]))

Solution (Python):
h, w = map(int, input().split())
a = []
c = 0
for i in range(h):
    b = list(input())
    if "
        a.append(b)
        c += 1
d = []
for i in range(w):
    e = []
    for j in range(c):
        e.append(a[j][i])
    else:
        d.append(e)
f = []
g = 0
for i in range(w):
    if "
        f.append(d[i])
        g += 1
h = []
for i in range(c):
    e = []
    for j in range(g):
        e.append(f[j][i])
    else:
        h.append(e)
for i in range(c):
    print(*h[i], sep="")

Solution (Python):
H,W=map(int,input().split())
A=[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):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7



H, W = MAP()
a = [input() for _ in range(H)]

ans = []
tate = []
yoko = []

for i in range(H):
	if a[i].count("
		yoko.append(i)

for i in range(W):
	for j in range(H):
		if a[j][i] == "
			tate.append(i)
			break

for y in yoko:
	tmp = ""
	for t in tate:
		tmp += a[y][t]
	ans.append(tmp)

print(*ans, sep="\n")

Solution (Python):
h,w=map(int,input().split())
l=[input() for i in range(h)]
m=[]
for i in range(h):
  if l[i]=='.'*w:
    m.append(i)
for x in m[::-1]:
  del l[x]
m=[]
for i in range(w):
  now=0
  for j in range(len(l)):
    if l[j][i]=='.':
      now+=1
  if now==len(l):
    m.append(i)
for x in m[::-1]:
  for i in range(len(l)):
    l[i]=l[i][:x]+l[i][x+1:]
[print(x) for x in l]

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

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

a = list(zip(*a))
d = []
for i in range(w):
  if set(a[i]) == {"."}: d.append(i)
d.sort(reverse=True)
for i in d:
  a.pop(i)

a = list(zip(*a))
for i in range(h):
  if i in skip: continue
  else:
    print("".join(a[i]))

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()
a = [input() for _ in range(H)]

ans = []
tate = []
yoko = []

for i in range(H):
	if a[i].count("
		yoko.append(i)

for i in range(W):
	for j in range(H):
		if a[j][i] == "
			tate.append(i)
			break

for y in yoko:
	tmp = ""
	for t in tate:
		tmp += a[y][t]
	ans.append(tmp)

print(*ans, sep="\n")

Solution (Python):
import itertools
import math
import sys
from copy import copy
import numpy as np

h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
skip_col = []
skip_row = []
for i in range(h):
    ok = True
    for j in range(w):
        if (a[i][j] == '
            ok = False
    if (ok):
        skip_col.append(copy(i))

for j in range(w):
    ok = True
    for i in range(h):
        if (a[i][j] == '
            ok = False
    if (ok):
        skip_row.append(copy(j))

xw = w - len(skip_row)
xh = h - len(skip_col)
ans = [['x' for _ in range(xw)] for _ in range(xh)]
xi = 0
xj = 0
for i in range(h):
    xj = 0
    added = False
    for j in range(w):
        if (i not in skip_col and j not in skip_row):
            ans[xi][xj] = a[i][j]
            added = True
            xj += 1
    if added:
        xi += 1

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

Solution (Python):
H, W = map(int, input().split())
A = []
b = ['.' for i in range(W)]
for i in range(H):
  a = list(input())
  if a != b:
    A.append(a)
m = len(A)
import numpy as np
A = np.array(A).T.tolist()
d = ['.' for i in range(m)]
C = []
for i in range(W):
  c = A[i]
  if c != d:
    C.append(c)
    
C = np.array(C).T.tolist()
n = len(C)
for i in range(n):
  ans="".join(C[i])
  print(ans)

Solution (Python):
import copy
H,W = map(int,input().split())
A = [list(input().strip()) for _ in range(H)]
while True:
    flag = 0
    for i in range(len(A)-1,-1,-1):
        fr = 0
        for j in range(len(A[0])):
            if A[i][j]=="
                fr = 1
                break
        if fr==0:
            B = [[0 for _ in range(len(A[0]))] for _ in range(len(A)-1)]
            for i1 in range(len(A)):
                if i1<i:
                    for j1 in range(len(A[0])):
                        B[i1][j1] = A[i1][j1]
                elif i1>i:
                    for j1 in range(len(A[0])):
                        B[i1-1][j1] = A[i1][j1]
            A = copy.deepcopy(B)
            flag = 1
    for j in range(len(A[0])-1,-1,-1):
        fc = 0
        for i in range(len(A)):
            if A[i][j]=="
                fc=1
                break
        if fc==0:
            B = [[0 for _ in range(len(A[0])-1)] for _ in range(len(A))]
            for j1 in range(len(A[0])):
                if j1<j:
                    for i1 in range(len(A)):
                        B[i1][j1] = A[i1][j1]
                elif j1>j:
                    for i1 in range(len(A)):
                        B[i1][j1-1] = A[i1][j1]
            A = copy.deepcopy(B)
            flag = 1
    if flag==0:break
for i in range(len(A)):
    print("".join(A[i]))

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

for y in range(h):
    for x in range(w):
        if block[y][x] == '.':
            
            nowy = 0
            nowx = 0
            flag = True
            while nowy < h:
                if block[nowy][x] == '.':
                    nowy += 1
                else:
                    flag = False
                    break
            if flag:
                for y_ in range(h):
                    ok[y_][x] = True
            flag = True
            while nowx < w:
                
                if block[y][nowx] == '.':
                    nowx += 1
                else:
                    flag = False
                    break
            if flag:
                for x_ in range(w):
                    ok[y][x_] = True
ans = []
for y in range(h):
    a = ""
    for x in range(w):
        if ok[y][x] != True:
            a += block[y][x]
    if len(a) != 0:
        ans.append(a)
print(*ans,sep='\n')

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

del_h = []
del_w = []

for i, h in enumerate(a):
    if "
        del_h.append(i)
for j in range(W):
    judge = True
    for k in range(H):
        if a[k][j] == "
            judge = False
    if judge:
        del_w.append(j)
for i in range(H):
    ans = ""
    for j in range(W):
        if i in del_h or j in del_w:
            pass
        else:
            ans += a[i][j]
    if len(ans) > 0:    
        print(ans)

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

h, w = [int(x) for x in input().split()]
a = []
for _ in range(h):
    b = list(input().rstrip())
    if '
        a.append(b)
h = len(a)
c = [1]*w
for i in range(w):
    flag = 1
    for j in range(h):
        if a[j][i] == "
            flag = 0
            break
    if flag:
        c[i] = 0
ans = []
for i in range(h):
    res = []
    for j in range(w):
        if c[j]:
            res.append(a[i][j])
    ans.append("".join(res))
for i in ans:
    print(i)

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

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

a = list(zip(*a))
d = []
for i in range(w):
  if set(a[i]) == {"."}: d.append(i)
d.sort(reverse=True)
for i in d:
  a.pop(i)

a = list(zip(*a))
for i in range(h):
  if i in skip: continue
  else:
    print("".join(a[i]))

Solution (Python):
h, w = map(int, input().split())
retu = [0 for i in range(w)]
gyou = [0 for i in range(h)]
lst = []
for i in range(h):
    ai = input()
    kuro = 0
    for j in range(w):
        if ai[j] == '
            kuro = 1
            retu[j] = 1
    if kuro == 1:
        gyou[i] = 1
    lst.append(ai)

ans = []
for i in range(h):
    if gyou[i] == 0: continue
    temp = ''
    for j in range(w):
        if retu[j] == 1:
            temp += lst[i][j]
    ans.append(temp)

for temp in ans:
    print(temp)

Solution (Python):
h, w = map(int, input().split())
A = []
for i in range(h):
    a = str(input())
    if a == '.'*w:
        continue
    else:
        A.append(a)

non_use = set()
for i in range(w):
    flag = True
    for j in range(len(A)):
        if A[j][i] == '
            flag = False
            break
    if flag:
        non_use.add(i)

ans = []
for i in range(len(A)):
    temp = ''
    for j in range(w):
        if j in non_use:
            continue
        else:
            temp += A[i][j]
    ans.append(temp)

for s in ans:
    print(s)

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

H, W = map(int, input().split())
a = [input()[:-1] for _ in range(H)]
f = [False]*W

for i in range(W):
    l = []
    
    for j in range(H):
        l.append(a[j][i])
    
    if l==['.']*H:
        f[i] = True

for i in range(H):
    if a[i]=='.'*W:
        continue
    
    ans = []
    
    for j in range(W):
        if not f[j]:
            ans.append(a[i][j])
    
    print(''.join(ans))

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


for i in range(w-1, -1, -1):
  count = 0
  for j in range(len(mat)):
    if mat[j][i] == ".":
      count += 1
  if count == len(mat):
    for j in range(len(mat)):
      mat[j].pop(i)

for h in range(len(mat)):
  print("".join(mat[h]))

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

tmp1 = [i for i in a if set(i) != {"."}]
tmp2 = [list(i) for i in zip(*tmp1)]
tmp3 = [i for i in tmp2 if set(i) != {"."}]
ans = [list(i) for i in zip(*tmp3)]
for i in ans:
    print("".join(i))

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

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

Hs = []
for i in range(H):
    flag = 0
    for j in range(W):
        if M[i][j]!=".":
            flag = 1
    if flag==1:
        Hs.append(i)

Ws = []
for j in range(W):
    flag = 0
    for i in range(H):
        if M[i][j]!=".":
            flag = 1
    if flag==1:
        Ws.append(j)

for i in Hs:
    out = []
    for j in Ws:
        out.append(M[i][j])
    print("".join(out))

Solution (Python):
n,m=map(int,input().split())
yoko=[input() for i in range(n)]
yokosiro=[0 if "
tatesiro=[]
for i in range(m):
    ta=[0 if yoko[j][i]=="
    if 0 in ta:
        tatesiro.append(0)
    else:
        tatesiro.append(1)
for i in range(n):
    if yokosiro[i]==0:
        print("".join([yoko[i][j] for j in range(m) if tatesiro[j]==0]))

Solution (Python):

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

for w in range(W):
    g = [a[h][w] for h in range(H)]
    if set(g) == {"."}:
        for h in range(H):
            a[h][w] = ""

for h in range(H):
    g = a[h]
    if set(g) != {"."} and set(g) != {"", "."}:
        print("".join(g))

Solution (Python):
def remove_row(l):
  ret = []
  for row in l:
    s = row[0]
    if any([e == "
      ret.append(row)
      
  return ret

def remove_col(l,w):
  num_row = len(l)
  num_col = w
  ret = [[""] for _ in range(num_row)]
  for i in range(num_col):
    if any([l[j][0][i] == "
      for k in range(num_row):
        ret[k] = [ret[k][0] + l[k][0][i]]
        
  return ret


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

l = remove_row(l)
l = remove_col(l,w)
for e in l:
  print(e[0])

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

remove_H = []
w_count = [0] * W
for h in range(H):
    if "
        remove_H.append(A[h])
        for i, w in enumerate(A[h]):
            if w == "
                w_count[i] += 1
remove_W = set([i for i, x in enumerate(w_count) if x != 0])
for h in remove_H:
    ans = [h[i] for i in range(W) if i in remove_W]
    print("".join(ans))

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H, W = MAP()
s = [input() for _ in range(H)]
s2 = []

for x in s:
	if x == "." * W:
		continue
	s2.append(x)



check = [1]*W

for i in range(len(s2)):
	for j in range(W):
		if s2[i][j] == "
			check[j] *= 0


for i in range(len(s2)):
	for j in range(W):
		if check[j] == 0:
			print(s2[i][j], end = "")
	print()

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

Solution (Python):
def resolve():
	h, w = map(int, input().split())
	grid = []
	for _ in range(h):
		grid.append(list(input()))
	for i in range(h):
		removable = True
		for j in range(w):
			if grid[i][j] == '
				removable = False
				break
		if removable:
			for j in range(w):
				grid[i][j] = False

	for i in range(w):
		for j in range(h):
			removable = True
			if grid[j][i] == '
				removable = False
				break
		if removable:
			for j in range(h):
				grid[j][i] = False
	for r in grid:
		ans = ""
		for el in r:
			if el:
				ans += el
		if ans:
			print(ans)
resolve()

Solution (Python):
h, w = map(int, input().split())
a = [''] * h
for i in range(h):
  a[i] = input()
  
row = [False] * h
col = [False] * w
for i in range(h):
  for j in range(w):
    if a[i][j] == '
      row[i] = True
      col[j] = True

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

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


yoko_new = []
for x in range(H):
    
    yoko_check = True
    for y in range(W):
        if hw[x][y] == "
            yoko_check = False
    if not yoko_check:
        yoko_new.append(hw[x])

yoko_new_len = len(yoko_new)

tate_new = [["-1" * W] * yoko_new_len]

z = 0
while z < len(yoko_new[0]):
    
    tate_check = True
    for w in range(yoko_new_len):
        if yoko_new[w][z] == "
            tate_check = False
    if tate_check:
        for w in range(yoko_new_len):
            yoko_new[w].pop(z)
    else:
        z += 1
for v in yoko_new:
    print("".join(v))

Solution (Python):
import sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
H,W = LI()
a = [S() for _ in range(H)]
a2,a3 = [],[]
for x in a:
    if '
        a2.append(x)
for y in zip(*a2):
    if '
        a3.append(y)
for z in zip(*a3):
    print(*z,sep='')

Solution (Python):
import numpy as np,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
H,W = LI()
a = np.array([[s for s in S()] for _ in range(H)])
a = a[(a=='
a = a.T
a = a[(a=='
a = a.T.tolist()
for x in a:
    print(*x,sep='')

Solution (Python):
h,w = map(int,input().split())
grid = []
datah = []
dataw = []
for i in range(h):
    l = list(input())
    grid.append(l)
    if l.count("
        datah.append(i)
for j in range(w):
    for k in range(h):
        if grid[k][j] == "
            break
    else:
        dataw.append(j)
for i in range(h):
    if i in datah:
        continue
    print("".join([grid[i][n] for n in range(w) if not n in dataw]))

Solution (Python):
def removeRow(matrix):
    _matrix = []
    for i in range(len(matrix)):
        if max(matrix[i]) == 1:
            _matrix.append(matrix[i])
    return _matrix

def removeCol(matrix):
    r = len(matrix)
    c = len(matrix[0])
    rightRotatedMatrix = []
    for i in range(c):
        col = []
        for j in range(r-1, -1, -1):
            col.append(matrix[j][i])
        rightRotatedMatrix.append(col)    
    rightRotatedMatrix = removeRow(rightRotatedMatrix)
    r = len(rightRotatedMatrix)
    c = len(rightRotatedMatrix[0])
    matrix = []
    for i in range(c-1, -1, -1):
        row = []
        for j in range(r):
            row.append(rightRotatedMatrix[j][i])
        matrix.append(row)
    return matrix

def answer(matrix):
    matrix = removeRow(matrix)
    return removeCol(matrix)

r, c = map(int, input().split())
matrix = []
for _ in range(r):
    row = [i for i in input()]
    for i in range(len(row)):
        if row[i] == '
            row[i] = 1
        if row[i] == '.':
            row[i] = 0
    matrix.append(row)
    
matrix = answer(matrix)
for i in range(len(matrix)):
    row = []
    for j in range(len(matrix[i])):
        if matrix[i][j] == 1:
            row.append('
        else:
            row.append('.')
    print("".join(row))

Solution (Python):
H, W = map(int, input().split())
a = []
for i in range(H):
  a.append(input())
cnt = 1
while cnt != 0:
  cnt = 0
  new = []
  for i in range(H):
    if a[i] == '.'*W:
      cnt += 1
    else:
      new.append(a[i])
  H = H - cnt
  cnt_2 = 0
  new_2 = ['' for _ in range(H)]
  for i in range(W):
    tmp = ''
    for j in range(H):
      tmp += new[j][i]
    if tmp == '.'*H:
      cnt_2 += 1
    else:
      for j in range(H):
        new_2[j] += tmp[j]
  cnt += cnt_2
  W = W - cnt_2
  a = new_2
for i in range(H):
  print(a[i])

Solution (Python):
h,w = map(int,input().split())
e = []
for i in range(h):
    e.append(list(input()))
rey = [0 for i in range(h)]
rex = [0 for i in range(w)]
for i in range(h):
    count = 0
    for j in range(w):
        if e[i][j] == ".":
            count += 1
    if count == w:
        rey[i] = 1

for i in range(w):
    count = 0
    for j in range(h):
        if e[j][i] == ".":
            count += 1
    if count == h:
        rex[i] = 1

for i in range(h):
    if rey[i]:
        continue
    else:
        for j in range(w):
            if rex[j]:
                continue
            else:
                print(e[i][j],end="")
    print()

Solution (Python):
h,w=map(int,input().split())
ans=[]
for i in range(h):
    x=input()
    if x!='.'*w:
        ans.append(x)
if len(ans)==0:
    print(*ans)
    exit()
flag=[0 for _ in range(w)]
for i in range(w):
    if ans[0][i]=='.':
        flag[i]=1
if len(ans)==1:
    for i in range(w):
        if flag[i]==0:
            print(ans[0][i],end='')
else:
    for i in range(1,len(ans)):
        for j in range(w):
            if flag[j]==1:
                if ans[i][j]!='.':
                    flag[j]=0
    for i in range(len(ans)):
        for j in range(w):
            if flag[j]==0:
                print(ans[i][j],end='')
        print()

Solution (Python):
M =[]
H,W = map(int, input().split())  
tate=[False]*H
yoko=[False]*W
for i in range(H):
    M.append(list(input()))

for i in range(H):
    for j in range(W):
        if M[i][j]=='
            tate[i]=True
            yoko[j]=True

for i in range(H):
    if tate[i]:
        out = ''
        for j in range(W):
            if yoko[j]:
                out = out + M[i][j]
        print(out)

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

has_black_rows = [False for _ in range(h)]
has_black_columns = [False for _ in range(w)]

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

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

Solution (Python):
h,w=map(int,input().split())
a=[]
for i in range(h):
    a.append(input())
H=[]
W=[]
for i in range(h):
    for j in range(w):
        if a[i][j]=="
            H.append(i)
            W.append(j)
H=set(H)
W=set(W)
for j in H:
    ans=[]
    for i in W:
        ans.append(a[j][i])
    print("".join(ans))

Solution (Python):
h, w=map(int, input().split())
a=[input() for _ in range(h)]
s=set()
t=set()
for i in range(h):
  if '
    s.add(i)
    for j in range(w):
      if a[i][j]=='
        t.add(j)
for i in s:
  l=''
  for j in t:
    l+=a[i][j]
  print(l)

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

row = [False]*h
col = [False]*w

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

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

Solution (Python):
h, w = map(int, input().split())
lis = [list(input()) for _ in range(h)]
cnt = 0
for i in reversed(range(h)):
    if set(lis[i])=={'.'}:
        lis.pop(i)
        cnt += 1
for j in reversed(range(w)):
    if set([l[j] for l in lis])=={'.'}:
        for k in range(h-cnt):
            lis[k].pop(j)
for m in lis:
    print("".join(m))