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

def Grid_Compression(h , w , ahl):

    ans = []
    hcount = []
    wcount = []

    for n in range(w):
        flag = True
        for m in range(h):
            if ahl[m][n] == "
                flag = False
        if flag == False:
            wcount.append(n)

    for n in range(h):
        flag = True
        for m in range(w):
            if ahl[n][m] == "
                flag = False
        if flag == False:
            hcount.append(n)

    for nh in hcount:
        ansli = []
        for nw in wcount:
            ansli.append(ahl[nh][nw])
        ans.append(ansli)

    return ans

def main():
    h , w = map(int , input().split())
    ahl = [list(str(input())) for i in range(h)]
    ans = Grid_Compression(h , w , ahl)
    for i in ans:
        pr = ""
        for w in i:
            pr += w
        print(pr)

if __name__ == '__main__':
    main()

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

grid=[[0 for j in range(w)] for i in range(h)]
tate=[]
ans=[]
for i in range(h):
    b=input()
    for j in range(w):
        grid[i][j]=b[j]

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

if len(tate)>1:
    tate=[n-i for i,n in enumerate(tate)]

for j in tate:
    for i in grid:
        i.pop(j)

for i in grid:
    if i.count('.')!=len(i):
        ans.append(i)

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

Solution (Python):










"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  h,w = map(int,input().split())
  rec = [list(input()) for _ in range(h)]
  
  flag = False
  
  for i in range(h):
    for j in range(w):
      if rec[i][j] == '.':
        flag = True
        pass
      else:
        flag = False
        break
    if flag:
      for r in range(w):
        rec[i][r] = 'd'
  
  
  
  
  for j in range(w):
    for i in range(h):
      if rec[i][j] == '.' or rec[i][j] == 'd':
        flag = True
        pass
      else:
        flag = False
        break
    if flag:
      for r in range(h):
        rec[r][j] = 'd'
        
  
  
  
  for i in range(h):
    new = ""
    for j in range(w):
      if rec[i][j] != 'd':
        new += rec[i][j]
    if len(new) != 0:print(new)
if __name__ == '__main__':
  main()

Solution (Python):
h, w = [int(x) for x in input().split()]
masu = [input() for i in range(h)]
for i in range(h):
  for j in range(w):
    if all([masu[i][k] == '.' for k in range(w)]):
      break
    elif all([masu[k][j] == '.' for k in range(h)]):
      continue
    else:
      print(masu[i][j], sep='', end='')
  else:
    print('')

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

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

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

Solution (Python):
n,m=map(int,input().split())
s=[]
for i in range(n):
  t=input()
  if '
    s.append(t)
s2=[list(x) for x in zip(*s)]
s3=[]
for i in range(m):
  if '
    s3.append(s2[i])
s4=[list(x) for x in zip(*s3)]
for i in s4:
  print("".join(map(str,i)))

Solution (Python):
H, W = map(int, input().split())
G = [list(input()) for _ in range(H)]
v = [g for g in G if g.count('.') != W]
for i in reversed(range(W)):
    chk = True
    for vv in v:
        if vv[i] == '
            chk = False
            break
    if chk:
        for vv in v:
            vv.pop(i)
for vv in v:
    print(''.join(vv))

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

delete_y=[]
for y in range(H):
    count=0
    for x in range(W):
        if a[y][x]=='.':
            count+=1
    if count==W:
        delete_y.append(y)

delete_x=[]
for x in range(W):
    count=0
    for y in range(H):
        if a[y][x]=='.':
            count+=1
    if count==H:
        delete_x.append(x)


for y in range(H):
    if y not in delete_y:
        row=''
        for x in range(W):
            if x not in delete_x:
                row+=(a[y][x])
        print(row)

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

h,w = LI()
a = [input() for _ in range(h)]
check_h = [True]*h
check_w = [True]*w
for i in range(h):
    for j in range(w):
        if a[i][j] == '
            break
    else:
        check_h[i] = False
for i in range(w):
    for j in range(h):
        if a[j][i] == '
            break
    else:
        check_w[i] = False

ans = []
for i in range(h):
    if check_h[i]:
        s = ''
        for j in range(w):
            if check_w[j]:
                s += a[i][j]
        ans.append(s)
for i in ans:
    print(i)

Solution (Python):
H,W = [int(x) for x in input().split()]
a = []
H2 = 0
W2 = 0
count = [0] * W
for i in range(H):
    l = list(input())
    if l != ["."]*W:
        a.append(l)
        H2 += 1
for i in range(W):
    flag = 1
    for j in range(H2):
        if a[j][i] != ".":
            flag = 0
            break
    count[i] = flag
for i in range(H2):
    an = []
    for j in range(W):
        if count[j] == 0:
            an.append(a[i][j])
    print("".join(an))

Solution (Python):
n,m=map(int,input().split())
s=[]
for i in range(n):
  t=input()
  if '
    s.append(t)
s2=[list(x) for x in zip(*s)]
s3=[]
for i in range(m):
  if '
    s3.append(s2[i])
s4=[list(x) for x in zip(*s3)]
for i in s4:
  print("".join(map(str,i)))

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

Solution (Python):
import numpy as np
H,W = map(int,input().split())
grid = []
ans = []
for i in range(H):
    h = list(input())
    if "
        grid.append(h)
grid = np.array(grid)
grid = grid.T
for i in range(len(grid)):
    w = grid[i]
    if "
        ans.append(w)
ans = np.array(ans).T
for i in ans:
    print("".join(i))

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    H, W = map(int, input().split())
    a = [input() for _ in range(H)]
    a = [w for w in a if w.count('

    ans = [''] * len(a)
    for i in range(W):
        isOK = False
        for s in a:
            if s[i] == '
                isOK = True
                break
        if isOK:
            for j, s in enumerate(a):
                ans[j] += s[i]
    print(*ans, sep='\n')

if __name__ == '__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    H, W = map(int, input().split())
    a = []
    for _ in range(H):
        w = input()
        if w.count('
            a.append(w)
    ans = [''] * len(a)
    for i in range(W):
        isOK = False
        for s in a:
            if s[i] == '
                isOK = True
                break
        if isOK:
            for j, s in enumerate(a):
                ans[j] += s[i]
    print(*ans, sep='\n')

if __name__ == '__main__':
    main()

Solution (Python):
N,M = list(map(int,input().split()))
A = []
for i in range(N):
    B = list(input())
    if "
        A.append(B)
    else:
        pass
after_A = []
Fafter_A = []
for i in range(M):
    C = ""
    for j in range(len(A)):
        C += A[j][i]
    after_A.append(C)
for i in range(M):
    if "
        Fafter_A.append(after_A[i])
    else:
        pass
for i in range(len(A)):
    D = ""
    for j in range(len(Fafter_A)):
        D += Fafter_A[j][i]
    print(D)

Solution (Python):
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
x, y = [], []
for i in range(h):
    c = 0
    for j in range(w):
        if a[i][j] == "
            c = 1
            break
    if c == 0:
        x.append(i)
for i in range(w):
    c = 0
    for j in range(h):
        if a[j][i] == "
            c = 1
            break
    if c == 0:
        y.append(i)
for i in range(h):
    if not i in x:
        for j in range(w):
            if not j in y:
                print(a[i][j], end = "")
        print()

Solution (Python):
import sys

def resolve():
    H, W = map(int, input().split(" "))
    cols = [input() for i in range(H)]
    skip_cols = []
    skip_rows = []
    for i, col in enumerate(cols):
        if col.replace(".", "") == "":
            skip_cols.append(i)
    for j in range(W):
        for col in cols:
            if col[j] == "
                break
        else:
            skip_rows.append(j)
    for i, col in enumerate(cols):
        if i in skip_cols:
            continue
        for j, c in enumerate(col):
            if j in skip_rows:
                continue
            sys.stdout.write(c)
        sys.stdout.write("\n")
    return

if '__main__' == __name__:
    resolve()

Solution (Python):
import numpy as np

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

def delete_rows(A):
  del_list = []
  for i, a in enumerate(A):
    if (a == '.').all():
      del_list.append(i)
  return np.delete(A, del_list, axis=0)


A = delete_rows(delete_rows(A).T).T
for a in A:
  print(''.join(a))

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

rows = [ False for _ in range(h) ]
cols = [ False for _ in range(w) ]


for y in range(h):
    is_ok = False
    for x in range(w):
        if a[y][x] != ".":
            is_ok = True
    if is_ok:
        rows[y] = True


for x in range(w):
    is_ok = False
    for y in range(h):
        if a[y][x] != ".":
            is_ok = True
    if is_ok:
        cols[x] = True

for y in range(h):
    if not rows[y]:
        continue
    for x in range(w):
        if rows[y] and cols[x]:
            print(a[y][x], end = "")
    print()

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

res = []
for h in range(H):
    for w in range(W):
        if grid[h][w] == "
            res.append(grid[h])
            break
    else:
        H -= 1

for w in range(W):
    for h in range(H):
        if res[h][w] == "
            break
    else:
        for i in range(H):
            res[i][w] = ""

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

Solution (Python):
import numpy as np
H, W = map(int, input().split())
I = [input() for i in range(H)]
I_n = [list(j) for j in I if '
h = np.array(I_n)
n = 0
for k in range (W):
  if '
    h = np.delete(h, n, 1)
  else:
    n += 1
H, W = h.shape
for l in range(H):
  A = ""
  for m in range(W):
    A += h[l, m]
  print(A)

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

mat=[]
for i in range(H):
  array=[x=="." for x in input()]
  mat.append(array)


allW_row=[]
for i in range(H):
  allW_line=True
  for j in range(W):
    if not mat[i][j]:
      allW_line=False
      break
  allW_row.append(allW_line)
  
allW_col=[]
for j in range(W):
  allW_line=True
  for i in range(H):
    if not mat[i][j]:
      allW_line=False
      break
  allW_col.append(allW_line)
  


for i in range(H):
  if allW_row[i]:
    continue
    
  array_list=[]
  for j in range(W):
    if not allW_col[j]:
      if mat[i][j]:
        array_list.append(".")
      else:
        array_list.append("
  print("".join(array_list))

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

Solution (Python):
H,W = map(int,input().split())
a=[]
for i in range(H):
  tmp=input()
  if tmp.count("
    pass
  else:
    a.append(list(tmp))
else:
  H=len(a)

  
Ignore_tate = []

for j in range(W):
  flag=True 
  for k in range(H):
    if a[k][j]=="
      flag=False
      break
  if flag:
    Ignore_tate.append(j)

for p in range(H):
  str=""
  for q in range(W):
    if q not in Ignore_tate:
      str += a[p][q]
  print(str)

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

maze = [list(input()) for _ in range(H)]

siro_yoko = []

for i in range(H):
    w_yoko = [False] * W
    for j in range(W):
        
        if maze[i][j] == '.':
            w_yoko[j] = True
    if all(w_yoko):
        siro_yoko.append(i)
    

siro_tate = []
for j in range(W):
    h_tate = [False] * H
    for i in range(H):
        if maze[i][j] == '.':
            h_tate[i] = True
    if all(h_tate):
        siro_tate.append(j)

for i in range(H):
    yoko = ""
    for j in range(W):
        if not i in siro_yoko and  j not in siro_tate:
            yoko += maze[i][j]
    if yoko:
        print(yoko)
    else:
        print('', end='')

Solution (Python):
[h,w] = [int(i) for i in input().split()]
a = []
t = 0
for i in range(h):
    tmp = input()
    if tmp != "." * w:
        a.append(tmp)
    else:
        t += 1
h -= t
ls = []
ans = []
for i in range(w):
    ls.append(i)
for i in range(w):
    intmp = 1
    for j in range(h):
        if a[j][i] == "
            intmp *= 0
    if intmp == 1:
        ls.pop(ls.index(i))
for i in range(h):
    tmp = ""
    for j in range(w):
        if j in ls:
            tmp += a[i][j]
    ans.append(tmp)

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

Solution (Python):
import numpy as np


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

lst = []
for i, row in enumerate(a):
    if np.all(row=='.'):
        lst.append(i)
a = np.delete(a, lst, 0)
b = a.T
lst = []
for i, row in enumerate(b):
    if np.all(row=='.'):
        lst.append(i)
b = np.delete(b, lst, 0)
ans = b.T
for i in ans:
    print(''.join(i))

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

rev_maze = [[0] * H for i in range(W)]
for i in range(W):
    for j in range(H):
        
        rev_maze[i][j] = maze[j][i]

ans_yoko = []
for i in range(H):
    if maze[i].count('.') == W:
        ans_yoko.append(i)
        
ans_tate = []
for i in range(W):
    if rev_maze[i].count('.') == H:
        ans_tate.append(i)

for i in range(H):
    ans = ''
    for j in range(W):
        
        if i in ans_yoko:
            continue
        if j in ans_tate:
            continue
        else:
            ans += maze[i][j]
    if i == any(ans_yoko) - 1:
        print(ans, end='')
    else:
        print(ans)

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

remove_W = []
remove_dict = {i:0 for i in range(W)}

for i in range(H):
    count_W = 0
    for j in range(W):
        if lists[i][j] == ".":
            remove_dict[j] += 1
            count_W += 1
            if count_W == W:
                remove_W.append(i)
            else:
                continue
remove_H = []
for key, value in remove_dict.items():
    if value == H:
        remove_H.append(key)

remove_H = reversed(remove_H)

for k in remove_H:
    for i in range(H):
        for j in range(W):
            if j == k:
                lists[i].pop(j)
            else:
                continue
remove_W = reversed(remove_W)

lists_pop = [lists.pop(i) for i in remove_W]

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

Solution (Python):
h,w = map(int,input().split())
l = list(list(input()) for i in range(h))
for i in l:
  if i.count('.') ==w:
    i.clear()
l= [i for i in l if i!=[]]

t = len(l)
for i in range(w):
  if all (l[q][i]=="." for q in range(t)):
    for q in range(t):
      l[q][i] =""
if "" in l:
  for z in l:
    z.remove("")
for m in l:
  print("".join(m))

Solution (Python):
h, w = map(int, input().split())
a = [["" for _ in range(w)] for _ in range(h)]
for y in range(h):
    s = input()
    for x in range(w):
        a[y][x] = s[x]
igny = [False] * h
ignx = [False] * w

def YYY(i, j):
    if j == h - 1:
        return a[j][i] == "."
    else:
        if YYY(i, j + 1):
            return a[j][i] == "."
    return False

def XXX(i, j):
    if i == w - 1:
        return a[j][i] == "."
    else:
        if XXX(i + 1, j):
            return a[j][i] == "."
    return False

for x in range(w):
    ignx[x] = YYY(x, 0)

for y in range(h):
    igny[y] = XXX(0, y)

for y in range(h):
    if igny[y] == False:
        for x in range(w):
            if ignx[x] == False:
                print(a[y][x], end = "")
        print()

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

y = [False]*H
x = [False]*W

for i in range(H):
    for j in range(W):
        if a[i][j] == "
            y[i] = True
            x[j] = True
            
for i in range(H):
    if y[i] == True:
        for j in range(W):
            if x[j] == True:
                print(a[i][j],end="")
        print()

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

B=[]
for h in range(H):
    if '
        B.append(A[h])

C=[]
for w in range(W):
    C.append([])

for h in range(len(B)):
    for w in range(W):
        C[w].append(B[h][w])

D=[]
for h in range(len(C)):
    if '
        D.append(C[h])

E=[]
for w in range(W):
    E.append([])

for h in range(len(D)):
    for w in range(len(D[h])):
        E[w].append(D[h][w])

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

Solution (Python):
h,w = map(int,input().split())
a = [""]*h
for i in range(h):
    a[i] = input()
row = [0]*h
col = [0]*w
for i in range(h):
    for j in range(w):
        if a[i][j] == "
            row[i] = 1
            col[j] = 1
for i in range(h):
    if row[i] == 1:
        for j in range(w):
            if col[j] == 1:
                print(a[i][j], end="")
        print()

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

for _ in range(h):
    t = input()
    if t=='.'*w: continue
    hw.append(t)
h=len(hw)
check=[0]*w
for i in range(h):
    for j in range(w):
        if hw[i][j]=='
            check[j]=1
p=0
for j in range(w):
    if check[j]==0:
        for i in range(h):
            hw[i]=hw[i][:j+p]+hw[i][j+1+p:]
        p-=1
for i in range(h):
    print(hw[i])

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

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

Solution (Python):

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

a = [""] * h
for i in range(h):
    a[i] = list(input())

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

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

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

        print()

Solution (Python):
H,W = map(int,input().split())
A = [input() for i in range(H)]
low = [False]*H
col= [False]*W
for l in range(H):
    for c in range(W):
        if A[l][c] == "
            low[l] = True
            col[c] = True
for l in range(H):
    if low[l] ==True:
        for c in range(W):
            if col[c]==True:
                print(A[l][c],end="")
        print()

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

row = []
for i in range(H):
    if '
        row.append(i)

column = []
for j in range(W):
    if all([F[i][j] == '.' for i in range(H)]):
        column.append(j)

ans = ''
for i in range(H):
    ret = False
    for j in range(W):
        if i not in row and j not in column:
            ans += F[i][j]
            ret = True
    if ret:
        ans += '\n'
print(ans)

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

HW = [[]]*H
h=0
for _ in range(H):
    Low = input()
    if Low!="."*W:
        HW[h] = list(Low)
        h+=1
        
HW_T = list(zip(*HW[:h]))

hw_t = [[]]*W
w=0

for s in HW_T:
    col= str(''.join(s))
    if col!="."*h:
        hw_t[w] = list(col)
        w+=1

HW = list(zip(*hw_t[:w]))

for l in HW:
    s = str(''.join(l))
    print(s)

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

valid_h=[]
valid_w=[]

for i in range(h):
    flg=False
    for j in range(w):
        if a[i][j] =="
            flg=True
    if flg:
        valid_h.append(i)

for j in range(w):
    flg=False
    for i in range(h):
        if a[i][j] =="
            flg=True
    if flg:
        valid_w.append(j)

ans=[]
for i in range(h):
    if not i in valid_h:
        continue

    tmp=[]
    for j in range(w):
        if j in valid_w:
            tmp.append(a[i][j])
    ans.append(tmp)

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

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

ans = []
for i in a:
    if "
        ans.append(i)

ans_T = list(zip(*ans))
ans = []

for i in ans_T:
    if "
        ans.append(i)

ans = list(zip(*ans))

for i in ans:
    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())
L = []
for i in range(h):
    L.append(list(input()))
L = [x for x in L if "
L = [x for x in zip(*L)]
L = [x for x in L if "
L = [x for x in zip(*L)]
for i in range(len(L)):
    print(*L[i],sep = "")

Solution (Python):

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

tmp = [[0 for _ in range(w)] for _ in range(h)] 
for i in range(h):
    for j in range(w):
        if a[i][j] == '.':
            tmp[i][j] = 0
        else:
            tmp[i][j] = 1

memo = []
for i in range(h):
    if sum(tmp[i]) == 0:
        memo.append(i)
memo2 = []
for i in range(w):
    sum_tmp = 0
    for j in range(h):
        sum_tmp += tmp[j][i]
    if sum_tmp == 0:
        memo2.append(i)

for i in range(h):
    if not i in memo:
        for j in range(w):
            if not j in memo2:
                print(a[i][j], end = '')
        print('')

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

h, w = MAP()
a = [list(STR()) for _ in range(h)]
i = 0
while i < len(a):
    if set(a[i]) == set(['.']):
        del a[i]
    else:
        i += 1
j = 0
while j < len(a[0]):
    arr = [a[i][j] for i in range(len(a))]
    if set(arr) == set(['.']):
        for i in range(len(a)):
            del a[i][j]
    else:
        j += 1
for i in range(len(a)):
    print(''.join(a[i]))

Solution (Python):



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


def main():
    r, c = [], []
    
    for i in range(H):
        if a[i] != "." * W:
            r.append(i)

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

    for i in r:
        for j in c:
            print(a[i][j], end="")
        print("")


if __name__ == "__main__":
    main()

Solution (Python):
H, W = map(int, input().split())
board = [input() for i in range(H)]
row, col = [], []
for i in range(H):
    c = sum(board[i][j] == '.' for j in range(W))
    row.append(c != W)
for j in range(W):
    c = sum(board[i][j] == '.' for i in range(H))
    col.append(c != H)
for i in range(H):
    for j in range(W):
        if row[i] and col[j]: print(board[i][j], end='')
    if row[i]: print()

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

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())
field = [input() for i in range(h)]

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

for i in range(h):
    for j in range(w):
        if field[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(field[i][j],end='')
            
        print()

Solution (Python):
import numpy as np


def main():
    h, w = map(int, input().split())
    board = [list(input()) for _ in range(h)]
    board_arr = np.array(board)

    del_h = np.where(np.all(board_arr == '.', axis=1))
    board_arr = np.delete(board_arr, del_h, axis=0)
    del_w = np.where(np.all(board_arr == '.', axis=0))
    board_arr = np.delete(board_arr, del_w, axis=1)
    for row in board_arr:
        row = row.tolist()
        ans = ''.join(row)
        print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import numpy
h,w = map(int,input().split())
grid = numpy.empty([h,w], str)
white_h = []
white_w = []
for i in range(h):
    grid[i] = list(input())
for i in range(h):
    if "
        white_h.append(i)
for i in range(w):
    if "
        white_w.append(i)
ans_grid = numpy.empty([h-len(white_h), w-len(white_w)], str)
cnt_h = 0
for i in range(h):
    if i not in white_h:
        cnt_w = 0
        for j in range(w):
            if j not in white_w:
                ans_grid[cnt_h, cnt_w] = grid[i,j]
                cnt_w += 1
        cnt_h += 1
for i in range(len(ans_grid)):
    print("".join(ans_grid[i]))

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

gyou=[False]*H
retu=[False]*W
for i in range(H):
    for j in range(W):
        if A[i][j]=="
            gyou[i]=True
            retu[j]=True
for i in range(H):
    if gyou[i]:
        for j in range(W):
            if retu[j]:
                print(A[i][j],end='')
        print()

Solution (Python):
h,w=map(int,input().split())
s=[input() for _ in range(h)]
a=[x for x in s if '
b=[x for x in zip(*a) if '

for i in zip(*b):
    print("".join(i))

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

Solution (Python):
h,w = map(int,input().split())
a = []
yoko = [False]*h
tate = [False]*w
for i in range(h):
    s = input()
    a.append(s)
cnt = 0
for i in range(h):
    state = False
    cnt = 0
    for j in range(w):
        if a[i][j] == ".":
            cnt += 1
    if cnt == w:
        yoko[i] = True
cnt = 0
for i in range(w):
    state = False
    cnt = 0
    for j in range(h):
        if a[j][i] == ".":
            cnt += 1
    if cnt == h:
        tate[i] = True

for i in range(h):
    if yoko[i] == True:
        continue
    else:
        ans = ""
        for j in range(w):
            if tate[j] == True:
                continue
            else:
                ans += a[i][j]
        print(ans)

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

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

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

Solution (Python):
h, w = map(int, input().split())
a = [''] * 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 = [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="")