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 numpy as np

h, w = map(int, input().split())
a = []
for i in range(h):
    a_i = input()
    if a_i != '.' * w:
        a.append(list(a_i))

b = [""] * len(a)

for j in range(w):
    for i in range(len(a)):
        if a[i][j] == "
            break

    if a[i][j] == "
        for ii in range(len(a)):
            b[ii] = b[ii] + a[ii][j]

for i in range(len(a)):
    print(b[i])

Solution (Python):

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

del_h = [False] * h
del_w = [False] * w

for i in range(h):
  if grid[i].count('
    del_h[i] = True

for j in range(w):
  del_w[j] = True
  for i in range(h):
    if grid[i][j] == '
      del_w[j] = False
      break

for i in range(h):
  if del_h[i]: continue
  row = ''.join([grid[i][j] for j in range(w) if not del_w[j]])
  print(row)

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    

    
    

    h,w = map(int, input().split())
    a = [list(input().rstrip()) for _ in range(h)]
    tate = []
    yoko = []
    for i in range(h):
        if '
            yoko.append(i)
    for i in range(w):
        for j in range(h):
            if a[j][i] == '
                break
        else:
            tate.append(i)
    res = []
    for i in range(h):
        temp = []
        if i in yoko:
            continue
        for j in range(w):
            if j in tate:
                continue
            temp.append(a[i][j])
        res.append(temp)
    for i in res:
        print(''.join(i))

if __name__ == '__main__':
    main()

Solution (Python):

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

del_h = [False] * h
del_w = [False] * w

for i in range(h):
  if grid[i].count('
    del_h[i] = True

for j in range(w):
  del_w[j] = True
  for i in range(h):
    if grid[i][j] == '
      del_w[j] = False
      break

for i in range(h):
  if del_h[i]: continue
  row = ''.join([grid[i][j] for j in range(w) if not del_w[j]])
  print(row)

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

A = [A[i] for i in range(h) if any(x == '
h = len(A)
ans = [[] for i in range(h)]
for i in range(w):
    if any(x[i] == '
        for j, x in enumerate(A):
            ans[j].append(x[i])
print(*[''.join(row) for row in ans], sep='\n')

Solution (Python):

from copy import deepcopy
h, w = map(int, input().split())
matrix = []
for _ in range(h):
    row = list(input())
    matrix.append(row)


rows = []
for i in range(h):
    white = False
    for j in range(w):
        if matrix[i][j] == '
            break
    else:
        white = True
    if white:
        rows.append(i)
t = []
for i in range(h):
    if i in rows:
        continue
    t.append(matrix[i])
h -= len(rows)
matrix = t


cols = []
for i in range(w):
    white = False
    for j in range(h):
        if matrix[j][i] == '
            break
    else:
        white = True
    if white:
        cols.append(i)

t = []
for i in range(h):
    row = []
    for j in range(w):
        if j in cols:
            continue
        row.append(matrix[i][j])
    t.append(row)
w -= len(cols)
matrix = t
for r in matrix:
    print(''.join(r))

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

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

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

l=[False]*H
c=[False]*W

for i in range(H):
  for j in range(W):
    if A[i][j]=='
      l[i]=True
      c[j]=True

ans=['' for i in range(H)]
for i in range(H):
  for j in range(W):
    if l[i] and c[j]:
      ans[i]+=A[i][j]
for i in range(H):
  if str(ans[i])!='':
    print(str(ans[i]))

Solution (Python):
gyo,retu = map(int,input().split())
ans = [0]*gyo
check = [0]*retu
flag1 = "ng"
for i in range(gyo):
    dum = input()
    for j in range(retu):
        if dum[j] == "
            flag1 = "ok"
            check[j] = 1
    if flag1 == "ok":
        ans[i] = dum
        flag1 = "ng"

for l in range(gyo-1,-1,-1):
    if ans[l] == 0:
        ans.pop(l)
ans_len = len(ans)

for k in range(retu-1,-1,-1):
    
    
    if check[k] == 0:
        for m in range(ans_len):
            dum3 = list(ans[m])
            dum3.pop(k)
            ans[m] = dum3
            
            
            

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

Solution (Python):



import sys
sys.setrecursionlimit(1 << 25)
ra = range
enu = enumerate

read = sys.stdin.readline


def read_map_as(H, replace={'
    '''
    文字列のmapを置換して読み込み。デフォでは
    '''
    ret = []
    for _ in range(H):
        ret.append([replace[s] for s in read()[:-1]])
        
        
    return ret


H, W = map(int, input().split())
A = read_map_as(H)
import numpy as np
A = np.array(A)

del_i = set()
for i in range(H):
    if A[i].sum() == 0:
        del_i.add(i)

del_j = set()
for j in range(W):
    if A[:, j].sum() == 0:
        del_j.add(j)


for i in range(H):
    if i in del_i:
        continue
    for j in range(W):
        if j in del_j:
            continue
        print('
    print()

Solution (Python):
h, w = map(int, input().split())
a = [input() for _ in range(h)]
r = [False]*h
c = [False]*w
for i in range(h):
    for j in range(w):
        if a[i][j] == "
            r[i] = True
            c[j] = True
for i in range(h):
    if r[i]:
        for j in range(w):
            if c[j]:
                print(a[i][j], end = "")
        print()

Solution (Python):
H ,W = map(int, input().split())
matrix = []
for i in range(H):
    m = list(input())
    matrix.append(m)
flag = True
while(flag):
    flag = False
    for i in range(H):
        if matrix[i].count(".")==W:
            del matrix[i]
            H -= 1
            flag = True
            break
    for i in range(W):
        cnt = 0
        for j in range(H):
            if matrix[j][i]==".":
                cnt += 1
        if cnt==H:
            for k in range(H):
                del matrix[k][i]
            flag = True
            W -= 1
            break
for i in matrix:
    print("".join(i))

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

for i in reversed(b):
    a.pop(i)

h-=len(b)
for i in range(w-1,-1,-1):
    flag=True
    for j in range(h-1,-1,-1):
        if a[j][i]=="
            flag=False
    if flag:
        for k in range(h-1,-1,-1):
            a[k]=a[k][:i]+a[k][i+1:]

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

Solution (Python):
h, w = [int(x) for x in input().split()]
A = []
B = []


rm_pos = [1]*w


for i in range(h):
    a = input()
    if a != '.' * w:
        A += [list(a)]


for j in range(w):
    for i in range(len(A)):
        if A[i][j] != '.':
            rm_pos[j] = 0 
            break




for i in range(len(A)):
    tmp = []
    for j, flg in enumerate(rm_pos):
        if flg == 0:
            tmp += A[i][j]
    B += [tmp]


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

Solution (Python):
h, w = [int(x) for x in input().split()]
A = []

rm_pos = [1]*w


for i in range(h):
    a = input()
    if a != '.' * w:
        A += [list(a)]


for j in range(w):
    for i in range(len(A)):
        if A[i][j] != '.':
            rm_pos[j] = 0 
            break


for j in range(w)[::-1]:
    if rm_pos[j] == 1:
        for i in range(len(A)):
            del A[i][j]


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

Solution (Python):
h, w = [int(x) for x in input().split()]
A = []
rm_pos = []

for i in range(h):
    a = input()
    if a != '.' * w:
        A += [list(a)]

flg = True


for j in range(w):
    for i in range(len(A)):
        if A[i][j] != '.':
            flg = False
            break
    if flg == True:
        rm_pos += [j]
    flg = True
rm_pos = reversed(rm_pos)


for j in rm_pos:
    for i in range(len(A)):
        del A[i][j]



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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)


def input(): return sys.stdin.readline().rstrip()

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

rows =[r for r in range(H) if '
columns = [c for c in range (W) if '

for r in rows:
    for c in columns:
        print(a[r][c], end="")
    print()

Solution (Python):
h,w = map(int,input().split(' '))
A = []
Ilist = [1]*w
for p in range(h):
    a=input()
    if '
        A.append(a)
        i = 0
        while i < w:
            if a[i] == '
                Ilist[i] *= 0
            i += 1

ans = ''
for a0 in A:
    k = 0
    while k < w:
        if Ilist[k] == 0:
            ans += a0[k]
        k += 1
    ans += '\n'
print(ans)

Solution (Python):
def solve():
    H, W = map(int, input().split())
    A = []
    for _ in range(H):
        inp = [s for s in input()]
        if inp != ['.']*W:
            A.append(inp)
    Ans = list(zip(*A))
    P = ['.' for _ in range(len(A))]
    while tuple(P) in Ans:
        Ans.remove(tuple(P))
    Ans = list(zip(*Ans))
    for i in range(len(Ans)):
        Ans[i] = ''.join(Ans[i])
    return Ans
print(*solve(),sep='\n')

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

    show_r = []
    show_c = []

    for r, row in enumerate(a):
        show_r.append(any(c == '

    for c, col in enumerate(zip(*a)):
        show_c.append(any(c == '

    ans = []
    for r in range(H):
        t = ''
        for c in range(W):
            if show_r[r] and show_c[c]:
                t += a[r][c]
        if t:
            ans.append(t)

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


if __name__ == '__main__':
    main()

Solution (Python):
icase=0
if icase==0:
    h,w=map(int,input().split())
    a=[]
    aid=["."]*w
    for i in range(h):
        ai=list(input())
        if ai!=aid:
            a.append(ai)
    b=[""]*len(a)
    for j in range(0,w):
        for i in range(len(a)):
            if a[i][j]=="
                break
        if a[i][j]=="
            for ii in range(len(a)):
                b[ii]=b[ii]+a[ii][j]
    for i in range(len(a)):
        print(b[i])

Solution (Python):
h,w = map(int, input().split())
aij = [list(input()) for i in range(h)]
aij1 = []
for r in aij:
    if r.count(".")==w:
        continue
    aij1.append(r)

h_r = len(aij1)
aij1_t = [[""]*h_r for i in range(w)]
for i in range(h_r):
    for j in range(w):
          aij1_t[j][i] = aij1[i][j]
          
ans_t = []
for c in aij1_t:
    if c.count(".") == h_r:
        continue
    ans_t.append(c)
    
w_r = len(ans_t)
ans = [[""]*w_r for i in range(h_r)]
for i in range(h_r):
    for j in range(w_r):
        ans[i][j] = ans_t[j][i]

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

Solution (Python):
import numpy as np
h,w=map(int,input().split())
maze=[]
for i in range(h):
  s=list(input())
  if s.count(".")==len(s):continue
  maze.append(s)
maze=np.array(maze).T
ans=[]
for i in range(10**5):
  try:q=maze[i]
  except:break  
  if all(x=="." for x in q):
      continue
  ans.append(q)
ans=((np.array(ans).T).tolist())
for i in ans:
  for j in i:
    print(j,end="")
  print()

Solution (Python):
def main():
  h,w = map(int, input().split())
  ans = []
  p = []
  for _ in range(h):
    s = input()
    if '
      ans.append(list(s))
  for i in range(len(ans[0])):
    for j in range(len(ans)):
      if ans[j][i] == '
        break
      if j == len(ans)-1:
        p.append(i)
  p.sort(reverse=True)
  for i in p:
    for j in range(len(ans)):
      ans[j].pop(i)
  for i in range(len(ans)):
    s = ''.join(ans[i])
    print(s)

if __name__ == '__main__':
  main()

Solution (Python):
def main():
  h,w = map(int, input().split())
  ans = []
  p = []
  for _ in range(h):
    s = input()
    if '
      ans.append(list(s))
  for i in range(len(ans[0])):
    for j in range(len(ans)):
      if ans[j][i] == '
        break
      if j == len(ans)-1:
        p.append(i)
  p.sort(reverse=True)
  for i in p:
    for j in range(len(ans)):
      ans[j].pop(i)
  for i in range(len(ans)):
    s = ''
    for j in range(len(ans[0])):
      s += ans[i][j]
    print(s)

if __name__ == '__main__':
  main()

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

for i in range(h):
    s = list(input())
    if s.count("
        p.append(s)
        cou += 1

q = {i for i in range(w)}

for i in range(cou):
    kar = set()
    for j in range(w):
        if p[i][j] == ".":
            kar.add(j)
    q = q & kar
    
s = {i for i in range(w)}
s = s - q
    
for i in range(cou):
    for j in s:
        print(p[i][j],end="")
    print()

Solution (Python):
H,W = map(int, input().split())
map =[]
for _ in range(H):
     a = list(input())
     map.append([int(x !='.') for x in a ])
memo = []
for i in range(H):
    if sum(map[i]) == 0:
        memo.append(i)
while memo:
    del map[memo[-1]]
    del memo[-1]
    H -= 1
for j in range(W):
    color = [map[x][j] for x in range(H)]
    if sum(color) == 0:
        memo.append(j)
while memo:
    for k in range(H):
        del map[k][memo[-1]]
    del memo[-1]
    W = -1
for j in map:
    a = ["." if ab == 0 else "
    print("".join(a))

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

yoko = []
for i in range(h):
    seta = set(a[i])
    if '
        yoko.append(a[i])

h = len(yoko)
w = len(yoko[0])
for i in range(w):
    tate = []
    for j in range(h):
        tate.append(yoko[j][i])
    settate = set(tate)
    if '
        for j in range(h):
            yoko[j][i] = ''

ans = ''
for i in range(h):
    c = ''.join(yoko[i])
    ans += c
    if i != h-1:
        ans += '\n'
print(ans)

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

ly = []
lt = []
for i in range(H):
  if "
    ly.append(i)
for j in range(W):
  c = 0
  for k in range(H):
    if m[k][j] == "
      c += 1
      break
  if c == 1:
    lt.append(j)    

for i in ly:
  s =""
  for j in lt:
    s += m[i][j]
  print(s)

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


b = [i for i in a if not i.count('.') == w]

h2 = len(b)
w2 = len(b[0])
ret = []
for i in range(w2):
    for x in range(h2):
        if b[x][i] == '
            ax = [b[xx][i] for xx in range(h2)]
            ret += [ax]
            break
    else:
        continue

for i in range(len(ret[0])):
    print(''.join([ret[x][i] for x in range(len(ret))]))

Solution (Python):
import sys
input = sys.stdin.readline
H, W = map(int, input().split())
S = [tuple(input()[:-1]) for _ in [0]*H]

ex = []
ey = []

for x in range(W):
    for s in S:
        if s[x] == '
            break
    else:
        ex.append(x)

for y in range(H):
    if '
        continue
    ey.append(y)

for y, s in enumerate(S):
    if y in ey:
        continue
    for x, t in enumerate(s):
        if x in ex:
            continue
        print(t, end="")
    print()

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

R = set()
C = set(list(range(W)))
for i in range(H):
    if not "
        R.add(i)
        continue
    tmp = set()
    for j in range(W):
        if A[i][j] == ".":
            tmp.add(j)
    C &= tmp

ans = []
for i in range(H):
    if i in R:
        continue
    tmp = []
    for j in range(W):
        if j in C:
            continue
        tmp.append(A[i][j])
    ans.append(tmp)

for a in ans:
    print(*a,sep="")

Solution (Python):
def main():
    h, w = map(int, input().split())
    a = [list(input()) for _ in range(h)]
    pass_row = []
    pass_col = []
    for i in range(h):
        if "
            pass_row.append(i)
    left_row = h - len(pass_row)
    for j in range(w):
        tmp = 0
        for i in range(h):
            if i not in pass_row and a[i][j] == ".":
                tmp += 1
        if tmp == left_row:
            pass_col.append(j)
    for i in range(h):
        if i not in pass_row:
            for j in range(w):
                if j not in pass_col:
                    print(a[i][j], end="")
            print()


if __name__ == '__main__':
    main()

Solution (Python):
H,W=map(int,input().split())
G=[list(input()) for i in range(H)]
hcnt,wcnt=set(),set()
for i in range(H):
    ok=True
    for j in range(W):
        if(G[i][j]=='
            ok=False
            break
    if(ok):
        hcnt.add(i)
for j in range(W):
    ok=True
    for i in range(H):
        if(G[i][j]=='
            ok=False
            break
    if(ok):
        wcnt.add(j)

for i in range(H):
    cnt=0
    if(i in hcnt):
        continue
    for j in range(W):
        if(j in wcnt):
            continue
        print(G[i][j],end='')
        cnt+=1
    if(cnt>0):
        print()

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

b = [list(x) for x in zip(*a)]

n = []
for i in range(W):
  if b[i] == ["."] * H: 
    n.append(i)

for A in a:
  if A == ["."] * W: continue
  if len(n) == 0: 
    print("".join(A))
    continue
  ans = ""
  for i in range(W):
    if i in n: continue
    ans += A[i]
  print("".join(ans))

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

for _ in range(h):
    row = input()
    if '
        mas.append(list(row))

ignore_col = []
for i in range(w):
    cnt = 0
    for j in range(len(mas)):
        if mas[j][i] == '
            break
        cnt += 1
    if cnt == len(mas):
        ignore_col.append(i)

for i in range(len(mas)):
    tmp = []
    for j in range(w):
        if j in ignore_col:
            continue
        tmp.append(mas[i][j])
    print(''.join(tmp))

Solution (Python):
h,w=map(int,input().split())
g=[list(input()) for _ in range(h)]
gg=[]
for l in zip(*g):
	if not all(x=="." for x in l):
		gg.append(l)
ggg=[]
for l in zip(*gg):
	if not all(x=="." for x in l):
		print("".join(l))

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

Solution (Python):
H, W = map(int, input().split())
a = [input() for _ in range(H)]
row = []
col = []
for i in range(H):
    if a[i] != '.' * W:
        row.append(i)
for j in range(W):
    if any(a[i][j] == '
        col.append(j)
ans = [''.join(a[r][c] for c in col) for r in row]
print(*ans, sep='\n')

Solution (Python):
h, w = map(int, input().split())
a = []
for i in range(h):
    t = list(input())
    a.append(t)
id = []
jd = []
for i in range(h):
    for j in range(w):
        if a[i][j] == '
            if i not in id:
                id.append(i)
            if j not in jd:
                jd.append(j)
jd.sort()
for i in id:
    for j in jd:
        print(a[i][j], end="")
    print()

Solution (Python):
h,w = map(int,input().split())
grid = []
curh = h
curw = w
for i in range(h):
    grid.append(list(input()))
i = 0
while i < curh:
    if grid[i] == ["."]*curw:
        for j in range(i,curh-1):
            grid[j] = grid[j+1]
        grid.pop(curh-1)
        curh -= 1
        i -= 1
    i += 1
i = 0
while i < curw:
    for j in range(curh):
        if grid[j][i] == "
            break
    else:
        for j in range(curh):
            for k in range(i,curw-1):
                grid[j][k] = grid[j][k+1]
            grid[j].pop(curw-1)
        curw -= 1
        i -= 1
    i += 1
for i in range(curh):
    print("".join(grid[i]))

Solution (Python):
h,w=map(int,input().split())
a=[list(input()) for i in range(h)]
c=[]
ng_h,ng_w=[],[]
for i in range(h):
  ok=True
  for j in range(w):
    if a[i][j]!=".":
      ok=False
      break
  if ok:
    ng_h.append(i)

for i in range(w):
  ok=True
  for j in range(h):
    if a[j][i]!=".":
      ok=False
      break
  if ok:
    ng_w.append(i)

for i in range(h):
  t=""
  for j in range(w):
    if i in ng_h:continue
    if j in ng_w:continue
    t+=a[i][j]
  if t!="":
    c.append(t)
print(*c,sep='\n')

Solution (Python):
h,w = map(int, input().split())
ans = []
for i in range(h):
    a = list(input())
    if a[0]=="." and len(set(a)) == 1:
        continue
    ans.append(a)

ans1 = []
for j in list(zip(*ans)):
    if j[0]=="." and len(set(j)) == 1:
        continue
    ans1.append(j)

for k in list(zip(*ans1)):
    print( ''.join(k))

Solution (Python):
h, w = map(int, input().split())
mapping = []
judge = "".join(["."]*w)
t = 0
for i in range(h):
  key = input()
  if key != judge:
    mapping.append([])
    for j in range(w):
      mapping[-1].append(key[j])
  else:
    t += 1

for i in range(w-1, -1, -1):
  for j in range(h-t):
    if mapping[j][i] == "
      break
    if j == h-t-1:
      for l in range(h-t):
        mapping[l].pop(i)

for i in range(h-t):
  print("".join(mapping[i]))

Solution (Python):
import itertools

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

area = []
for i in range(h):
    array = list(input())
    area.append(array)

a = list(itertools.chain.from_iterable(area))

yoko = []
tate = []

for i in range(h):
    cnt = 0
    for j in range(w):
        if area[i][j] == '
            cnt += 1
    if cnt == 0:
        yoko.append(i)

for i in range(w):
    b = a[i::w]
    if len(set(b)) == 1 and '.' in set(b):
        tate.append(i)

for i in range(h):
    flg = False
    for j in range(w):
        if j in set(tate):
            continue
        elif i in set(yoko):
            flg = True
            continue
        else:
            print(area[i][j], end='')
    if flg == False:
        print()

Solution (Python):
h,w = map(int,input().split())
a = [list(input()) for _ in range(h)]
y= 0
while y < h:
    x = 0
    flag = True
    while x < w:
        if a[y][x]=="
            flag = False
        x += 1
    if flag == True:
        a.pop(y)
        h -= 1
        y = 0
    else:
    	y += 1
x = 0
while x < w:
    y = 0
    flag = True
    while y < h:
        if a[y][x]=="
            flag = False
        y += 1
    if flag == True:
        for i in range(h):
            a[i].pop(x)
        w -= 1
        x = 0
    else:
    	x += 1

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

Solution (Python):
import numpy as np


def main():
    h, w = map(int, input().split())
    l = []
    for _ in range(h):
        a = list(input())
        if not '
            continue
        l.append(a)
    l = np.array(l)
    m = np.rot90(l)
    n = []
    for a in m:
        if not '
            continue
        n.append(a)
    ans = np.array(n)
    ans = np.rot90(ans, -1)
    for i in ans:
        print(*i, sep='')


if __name__ == "__main__":
    main()

Solution (Python):
from sys import stdin,setrecursionlimit
setrecursionlimit(10 ** 7)
h,w = map(int,stdin.readline().rstrip().split())
li = [["" for i in range(w)]for j in range(h)]
for i in range(h):
    s = stdin.readline().rstrip()
    for j in range(w):
        li[i][j] = s[j]
lin = []
for i in li:
    if i != ["."]*w:
        lin.append(i)
out = []
for i in range(w):
    flag = True
    for j in range(len(lin)):
        if lin[j][i] == "
            flag = False
    if flag:
        out.append(i)

lis = []
for i in lin:
    case = []
    for j,k in enumerate(i):
        if j in out:
            continue
        case.append(k)
    lis.append(case)

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

Solution (Python):
h,w = map(int,input().split())
grid = []
for i in range(h):
    grid.append(list(input()))
h_b = []
w_b = []
for i in range(h):
    if "
        h_b.append(i)
grid_t = [list(x) for x in zip(*grid)]
for i in range(w):
    if "
        w_b.append(i)
ans = []
for i in h_b:
    crt = []
    for j in w_b:
        crt.append(grid[i][j])
    ans.append(crt)
for i in range(len(ans)):
    print("".join(ans[i]))

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

h, w = map(int, readline().split())
a = [readline().rstrip().decode() for i in range(h)]
memo_w = [False] * h
memo_h = [False] * w
for i in range(h):
    flag = True
    for j in range(w):
        if a[i][j] == '
            flag = False
            break
    if flag:
        memo_w[i] = True
for i in range(w):
    flag = True
    for j in range(h):
        if a[j][i] == '
            flag = False
            break
    if flag:
        memo_h[i] = True
for i in range(h):
    if not memo_w[i]:
        ans = ''
        for j in range(w):
            if not memo_h[j]:
                ans += a[i][j]
        print(ans)

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

skip_col = [False] * W
for i in range(len(board[0])):
    for j in range(H):
        if board[j][i] == '
            break
    else:
        skip_col[i] = True

for i in range(H):
    if all([c == '.' for c in board[i]]):
        continue
    for j in range(W):
        if skip_col[j]:
            continue
        print(board[i][j], end='')
    print('')

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,m = inpl()
s = [list(input()) for i in range(n)]
ss = []
for i in range(n):
    if s[i].count('.') == m:
        continue
    ss.append(s[i])
sss = [[]for _ in range(len(ss))]
for i in range(m):
    ok = False
    ln = len(ss)
    for j in range(ln):
        if ss[j][i] == '
            ok = True
    if ok:
        for j in range(ln):
            sss[j].append(ss[j][i])

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

Solution (Python):
def main():
    H, W = (int(i) for i in input().split())
    A = [input() for i in range(H)]
    cut_h = []
    cut_w = []
    for h in range(H):
        if all(s == "." for s in A[h]):
            cut_h.append(h)
    for w in range(W):
        if all("." == A[i][w] for i in range(H)):
            cut_w.append(w)
    for h in range(H):
        if h in cut_h:
            continue
        for w in range(W):
            if w in cut_w:
                continue
            print(A[h][w], end="")
        print()


if __name__ == '__main__':
    main()

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

skip_col = [False] * W
for i in range(len(board[0])):
    for j in range(H):
        if board[j][i] == '
            break
    else:
        skip_col[i] = True

for i in range(H):
    if all([c == '.' for c in board[i]]):
        continue
    for j in range(W):
        if skip_col[j]:
            continue
        print(board[i][j], end='')
    print('')

Solution (Python):
def main():
    H, W = map(int, input().split())
    cell = [list(input()) for _ in range(H)]
    rlist = list()
    clist = list()
    for i in range(H):
        if cell[i].count(".") == W:
            rlist.append(i)
    for j in range(W):
        c = 0
        for i in range(H):
            if cell[i][j] == ".":
                c += 1
            if c == H:
                clist.append(j)
    for i in range(H):
        if i in rlist:
            pass
        else:
            for j in range(W):
                if j in clist:
                    pass
                else:
                    print(cell[i][j], end="")
            print()
main()

Solution (Python):

import io

n, m = map(int, input().split())
array = []

for i in range(n-1, -1, -1):
    qwe = list(input())
    if qwe!=["."]*m:
        array.append(qwe)

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

for i in range(len(array)):
    print("".join(array[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=[[j for j in input()] for i in range(h)]
b=[x for x in a if "
c=zip(*[y for y in zip(*b) if "
for d in c:print("".join(d))

Solution (Python):
import numpy as np


def yoko(row):
    cnt = sum(row)
    return cnt == len(row)


def main():
    h, w = map(int, input().split(' '))
    a = []

    for i in range(h):
        b = input()
        a += [1 if c == '.' else 0 for c in b]
    a = np.array(a).reshape(h, w)

    while True:
        cnt = 0
        del_list = []
        for i in range(len(a)):
            judge = yoko(a[i])
            if judge:
                del_list.append(i)

        if len(del_list):
            del_cnt = 0
            for idx in del_list:
                a = np.delete(a, idx - del_cnt, axis=0)
                del_cnt += 1
        else:
            cnt += 1

        a = a.T

        del_list = []
        for i in range(len(a)):
            judge = yoko(a[i])
            if judge:
                del_list.append(i)

        if len(del_list):
            del_cnt = 0
            for idx in del_list:
                a = np.delete(a, idx - del_cnt, axis=0)
                del_cnt += 1
        else:
            cnt += 1

        a = a.T

        if cnt >= 2:
            break

    for i in range(len(a)):
        r = ''
        for j in a[i]:
            if j == 1:
                r += '.'
            else:
                r += '
        print(r)


main()