Problem:
 Score : 200 points    Problem Statement There is a grid of squares with H horizontal rows and W vertical columns.
The square at the i -th row from the top and the j -th column from the left is represented as (i, j) .
Each square is black or white.
The color of the square is given as an H -by- W matrix (a_{i, j}) .
If a_{i, j} is . , the square (i, j) is white; if a_{i, j} is # , the square (i, j) is black.  Snuke is compressing this grid.
He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:   Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.   It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.
Find the final state of the grid.      Constraints  1 \leq H, W \leq 100  a_{i, j} is . or # .  There is at least one black square in the whole grid.         Input Input is given from Standard Input in the following format:  H  W  a_{1, 1}...a_{1, W}  :  a_{H, 1}...a_{H, W}       Output Print the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.        Sample Input 1 4 4
##.#
....
##.#
.#.#      Sample Output 1 ###
###
.##  The second row and the third column in the original grid will be removed.       Sample Input 2 3 3
#..
.#.
..#      Sample Output 2 #..
.#.
..#  As there is no row or column that consists only of white squares, no operation will be performed.       Sample Input 3 4 5
.....
.....
..#..
.....      Sample Output 3 #       Sample Input 4 7 6
......
....#.
.#....
..#...
..#...
......
.#..#.      Sample Output 4 ..#
#..
.#.
.#.
#.#

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


for j in range(W-1, -1, -1):
    flag = True

    for i in range(H):
        if a[i][j] != '.':
            flag = False
            break

    if flag:
        for i in range(H):
            a[i].pop(j)
        W -= 1


for i in range(H):
    flag = True

    for j in range(W):
        if a[i][j] == '.':
            continue
        else:
            flag = False
            break

    if flag:
        continue
    else:
        print(''.join(a[i]))

Solution (Python):
n,m = map(int,input().split())
l = [list(input()) for i in range(n)]
gyou = []
retsu = []
count = 0
for i in range(n):
    a = "."
    count = 0
    for j in range(m):
        if a == l[i][j]:
            count += 1
    if count != m:
        gyou.append(i)
for i in range(m):
    a = "."
    count = 0
    for j in range(n):
        if a == l[j][i]:
            count += 1
    if count != n:
        retsu.append(i)

for i in range(n):
    if i in gyou:
        for j in range(m):
            if j in retsu:
                if j == retsu[-1]:
                    print(l[i][j])
                else:
                    print(l[i][j],end="")

Solution (Python):
h, w = map(int,input().split())
aList = []
for i in range(h):
  aList.append(list(input()))
for i in range(h-1,-1,-1):
  if aList[i].count('
    aList.pop(i)

aList = list(zip(*aList))
for i in range(w-1,-1,-1):
  if aList[i].count('
    aList.pop(i)

aList = list(zip(*aList))

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

Solution (Python):
import sys

INPUT = lambda: sys.stdin.readline().rstrip()
MAP = lambda: map(int, INPUT().split())

sys.setrecursionlimit(10 ** 9)


def main():
    H, W = MAP()
    A = [INPUT() for _ in range(H)]

    ans_H = []
    for y in range(H):
        for x in range(W):
            if A[y][x] == '
                ans_H.append(y)
                break

    ans_W = []
    for x in range(W):
        for y in range(H):
            if A[y][x] == '
                ans_W.append(x)
                break

    ans = ["" for _ in range(len(ans_H))]
    for i, h in enumerate(ans_H):
        for w in ans_W: ans[i] += A[h][w]

    for a in ans: print(a)


if __name__ == '__main__':
    main()

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

x = []
y = []
for i in range(h):
    if "
        y += [i]
for i in range(w):
    t = []
    for j in range(h):
        t.append(a[j][i])
    if "
        x += [i]

for i in y:
    for j in x:
        print(a[i][j], end="")
    print()

Solution (Python):
H, W = map(int, input().split())
graph = [list(input()) for _ in range(H)]
flg = True
while flg:
    loop = False
    for i in range(len(graph)):
        if "
            graph.pop(i)
            loop = True
            break
    if loop:
        continue
    for j in range(len(graph[0])):
        tate = [line[j] for line in graph]
        if "
            for i in range(len(graph)):
                graph[i].pop(j)
            break
    else:
        flg = False
for line in graph:
    print("".join(line))

Solution (Python):
H,W=map(int,input().split())
S=[list(input()) for _ in range(H)]
A=[False]*H
B=[False]*W
for i in range(H):
  for j in range(W):
    if S[i][j]=='
      A[i]=True
      B[j]=True

for i in range(H):
  if A[i]:
    for j in range(W):
      if B[j]:
        print(S[i][j], end = '')
    print()

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

res = []
for i in range(h):
    line = input()
    if '
        res.append(line)

ok_v_line = []
for i in range(w):
    v_line = [line[i] for line in res]
    if '
        ok_v_line.append(i)

for line in res:
    final_line = [line[x] for x in ok_v_line]
    print(''.join(final_line))

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

for i in range(0, max(h, w)):
   row = [x.count('.') for x in a]
   a = [x for x, k in zip(a, row) if k < len(x)]

   b = [list(x) for x in zip(*a)]
   line = [x.count('.') for x in b]
   b = [x for x, k in zip(b, line) if k < len(x)]
   a = [list(x) for x in zip(*b)]

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

Solution (Python):
h, w = map(int, input().split())
l = []
for i in range(h):
    retu = list(input())
    if "
        l.append(retu)
ll = []
for i in zip(*l):
    if "
        ll.append(i)
for i in zip(*ll):
    print("".join(i))

Solution (Python):
import functools
import numpy as np


def get_bool(x, value, axis):
    return np.where(x == value, True, False).all(axis=axis)


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

custom_get_bool = functools.partial(get_bool, mat, '.')
mat = mat[:, ~custom_get_bool(0)]
mat = mat[~custom_get_bool(1)]
print('\n'.join([''.join(row) for row in mat]))

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


def get_bool(x, value, axis):
    return np.where(x == value, True, False).all(axis=axis)


mat = mat[:, ~get_bool(mat, '.', 0)]
mat = mat[~get_bool(mat, '.', 1)]
print('\n'.join([''.join(row) for row in mat]))

Solution (Python):
import numpy as np
H, W = map(int, input().split())
mat = np.array([list(input()) for _ in range(H)])
mat = mat[:, ~np.where(mat == '.', True, False).all(axis=0)]
mat = mat[~np.where(mat == '.', True, False).all(axis=1)]

print('\n'.join([''.join(row) for row in mat]))

Solution (Python):
import numpy as np
H, W = map(int, input().split())
mat = np.array([list(input()) for _ in range(H)])
bools = np.where(mat == '.', True, False)
mat = mat[:, ~bools.all(axis=0)]
bools = np.where(mat == '.', True, False)
mat = mat[~bools.all(axis=1)]

print('\n'.join([''.join(row) for row in mat]))

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


ans = []
for i in range(H):
    row = mat[i]
    if all(['.' == r for r in row]):
        continue
    ans.append(row)

columns = [''.join([a[w] for a in ans]) for w in range(W)]
tmp = len(ans)
columns = [c for c in columns if '.' * tmp != c]

ans = [''.join([c[i] for c in columns]) for i in range(len(columns[0]))]
print('\n'.join(ans))

Solution (Python):
h, w = map(int, input().split())
a = []
delcol = {i: True for i in range(w)}
for _ in range(h):
    _a = input()
    if _a == "."*w:
        continue

    for _w in range(w):
        delcol[_w] &= ("." == _a[_w])

    a.append(_a)

for _a in  a:
    for _w in range(w):
        if not delcol[_w]:
            print(_a[_w], end="")

    print()

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

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

w_set = list(set(w))
for x in range(len(w_set)):
  if w.count(w_set[x]) == H:
    w_list.append(w_set[x])

for i in range(H):
  A = ""
  if a[i] != "." * W:
    for j in range(W):
      if not j in w_list:
        A += a[i][j]
    print(A)

Solution (Python):
h, w = map(int, input().split())
A = [ input() for _ in range(h) ]
H, W = [], []
for i in range(h):
    if A[i].count('.')==w:
        H.append(i)
for j in range(w):
    if [ A[i][j] for i in range(h) ].count('.')==h:
        W.append(j)
for i in range(h):
    if i in H:
        continue
    for j in range(w):
        if j in W:
            continue
        print(A[i][j], end='')
    print()

Solution (Python):
H, W = map(int, input().split())
A = [input() for _ in range(H)]
A = [aa for aa in A if any(a=="
A = list(map(list, zip(*A)))
A = [aa for aa in A if any(a=="
A = list(map(list, zip(*A)))
for aa in A:
    print("".join(aa))

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

A = ""

for _ in range(H):
  s = input()
  if len(set(s)) == 1 and s == "." * W:
    H -= 1
  else:
    for i in s:
      A += i

if len(A) == 0:
  print(A)

else:
  M = []

  for i in range(W):
    if A[i] == ".":
      for j in range(i + W,H * W,W):
        if A[j] == "
          break
      else:
        M.append(i)

  A = [A[i] for i in range(H * W) if not (i % W) in M]
  W = W - len(M)
  
  S = ""
  
  for i in range(H * W):
    S += A[i]
    if (i + 1) % W == 0:
      print(S)
      S = ""

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

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

use_cols = []
use_rows = []

for hi in range(h):
  flag = False
  for wi in range(w):
    if aa[hi][wi] == '
      flag = True
      break
  if flag:
    use_rows.append(hi)

for wi in range(w):
  flag = False
  for hi in range(h):
    if aa[hi][wi] == '
      flag = True
      break
  if flag:
    use_cols.append(wi)
    
ans = [[' ']*(w-len(use_cols)) for _ in range(h-len(use_rows))]

ans =[]
for hi in use_rows:
  row = ''
  for wi in use_cols:
    row+=aa[hi][wi]
  ans.append(row)
  
for a in ans:
  print(a)

Solution (Python):
import sys

h, w = map(int, sys.stdin.readline().split())
grid = [sys.stdin.readline().rstrip() for _ in range(h)]

def main():
    res = [list(s) for s in grid if '
    res2 = []
    for j in range(w):
        t = [s[j] for s in res]
        if '
            res2.append(t)
    
    for j in range(len(res)):
        yield ''.join([s[j] for s in res2])

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

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

a = []
for _ in range(h):
    wk = input()

    if '
        a.append(wk)

t = []
for j in zip(*a):
    if '
        t.append(j)

for list in zip(*t):
    print("".join(list))

Solution (Python):






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

ans1 = []
ans2 = [[0 for _ in range(w)] for _ in range(h)]

for i in range(h):
    if not("
        continue
    else:
        ans1.append(a[i])

cnt = 0
for i in range(w):
    bre = True
    for j in range(len(ans1)):
        if ans1[j][i] == "
            bre = False
    if not(bre):
        for k in range(len(ans1)):
            ans2[k][cnt] =  ans1[k][i]
        cnt += 1

for i in range(h):
    for j in range(w):
        if ans2[i][j] != 0:
            print(ans2[i][j],end="")
    print()

Solution (Python):
h, w = map(int, input().split())
table = []
for _ in range(h):
    line = input()
    if line.count(".") != w:
        table.append(line)
table = [list(x) for x in zip(*table)]
ans = []
for t in range(len(table)):
    if table[t].count(".") != len(table[t]):
        ans.append(table[t])
ans = [list(x) for x in zip(*ans)]
for a in ans:
    print("".join(a))

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

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

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

grid=[]
result=[]

for i in range(h):
    buf=input()
    if len(buf) == buf.count("."):
        continue
    else:
        grid.append(buf)

for x in zip(*grid):
    if len(x) == x.count("."):
        continue
    else:
        result.append(x)

for x in zip(*result):
    print("".join(x))

Solution (Python):
import sys
import numpy as np
input = sys.stdin.readline
H, W = map(int, input().split())
a = [list(input().strip()) for _ in range(H)]
a = [ai for ai in a if "
H = len(a)
a_T = np.array(a).T
a_T = [ai for ai in a_T if "
a = np.array(a_T).T
W = len(a[0])
for i in range(H):
    for j in range(W):
        print(a[i][j],end="")
    print("")

Solution (Python):
import sys
input = sys.stdin.readline
H,W = [int(i) for i in input().split()]
nes = ['0'] * H
for i in range(H) :
    li = list(input())
    nes[i] = li
yoko = [False] * H
tate = [False] * W
for i in range(H) :
    for j in range(W) :
        if nes[i][j] == "
            yoko[i] = True
            tate[j] = True
for i in range(H) :
    if yoko[i] :
        for j in range(W) :
            if tate[j] :
                print(nes[i][j],end = '')
        print()

Solution (Python):
import sys
input = sys.stdin.readline
H,W = [int(i) for i in input().split()]
nes = ['0'] * H
indexa = []
for i in range(H) :
    li = list(input())
    nes[i] = li
for i in range(H) :
    del nes[i][-1]
a = 0
for i in range(H) :
    for j in range(W) :
        if nes[i][j] == "
            a = 1
            break
    if a == 0 and nes[i][W-1] == "." :
        indexa.append(i)
    a = 0
count = 0
for i in indexa :
    del nes[i-count]
    count+=1
length = len(nes)
indexaa = []
b = 0
for j in range(W) :
    for i in range(length) :
        if nes[i][j] == "
            b = 1
            break
    if nes[length-1][j] == "." and b == 0 :
        indexaa.append(j)
    b = 0
counta = 0
for i in indexaa :
    for j in range(length) :
        del nes[j][i-counta]
    counta+=1
for i in range(length) :
    t = ''.join(nes[i])
    print(t)

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

    A = []
    grid = []
    for i in range(h):
        A.append(input())
    gird = []

    for i in range(h):
        if A[i] != '.'*w:
            grid.append(A[i])

    A = grid.copy()
    w_tmp = len(A[0])
    h_tmp = len(A)
    grid = ['' for _ in range(h_tmp)]
    for i in range(w_tmp):
        tmp = 0
        for j in range(h_tmp):
            if A[j][i] == '.':
                tmp += 1
        if tmp != h_tmp:
            for j in range(h_tmp):
                grid[j] += A[j][i]
    for i in range(len(grid)):
        print(grid[i])


if __name__ == '__main__':
    main()

Solution (Python):
H,W = map(int, input().split())
A = [input() for _ in range(H)]
A = [a for a in A if a != '.'*W]
A_t = [list(a) for a in zip(*A)]
A_t = [list(a) for a in A_t if '
A = [a for a in zip(*A_t)]

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

Solution (Python):
i,j=map(int,input().split())
li=[]
for s in range(i):
    p=str(input())
    li.append(p)
def provre(x):
    lll=0
    br=0
    for z in range(len(x)):
        if x[z]=='.':
            br+=1
    if br==len(x):
        lll=1
    return(lll)
li2=[]
for a in range(len(li)):
    if provre(li[a])==0:
        li2.append(li[a])
li=li2

def prost(x):
    sd=[]
    L = [1] * len(x[0])
    for i in range(len(x[0])):
        ooo=1
        cnt = 0
        for s in range(len(x)):
            if x[s][i]=='.':
                cnt += 1
        if cnt == len(x):
            ooo = 0
        if ooo==0:
            L[i] = 0
              
    for j in range(len(x)):
        s = ""
        for q in range(len(x[0])):
            if L[q]==1:
                s+=x[j][q]
        sd.append(s)
    for ka in range(len(sd)):
        print(sd[ka])


prost(li)

Solution (Python):


def provjera(listaznakova):
    x = 0
    for znak in listaznakova:
        if znak == ".":
            x = x+1
    if x == len(listaznakova):
        return False
    else:
        return True
            
    
h,w = map(int,input().split())
matrica = []
matrica_dva = []
matrica_tri = []
matrica_cet = []
matrica_rez = []
red_t = []



for x in range(h):
    red=input()
    matrica.append(red)
    
for c in matrica:
    if provjera(c):
        matrica_dva.append(c)
    else:
        h-=1
    
for x in range(w):
    for y in range(h):
        red_t.append(matrica_dva[y][x])
    matrica_tri.append(red_t)
    red_t = []

for c in matrica_tri:
    if provjera(c):
        matrica_cet.append(c)
    else:
        w-=1
red_t = []

for x in range(h):
    for y in range(w):
        red_t.append(matrica_cet[y][x])
    matrica_rez.append(red_t)
    red_t = []

for x in range(h):
    print("".join(matrica_rez[x]))

Solution (Python):
h,w = map(int, input().split())
g = []
for i in range(h):
  c = input()
  if '
    continue
  g.append(c)
h = len(g)
memo = []
for i in range(w):
  f = 1
  for j in range(h):
    if g[j][i] == '
      f = 0
  if f:
    memo.append(i)
for j in range(h):
  print(''.join([g[j][i] for i in range(w) if i not in memo]))

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

d_h = []
d_w = []
for i in range(h):
    if "
        d_h.append(i)
for i in range(w):
    if "
        d_w.append(i)

ary = np.delete(ary, d_h, 0)
ary = np.delete(ary, d_w, 1)

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

Solution (Python):

 
import math
import itertools
import sys
import copy
 





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


for i in range(H) :
  wcnt = 0
  for j in range(W) :
    if A[i][j] == "." :
      wcnt += 1
  if wcnt == W :
    for j in range(W) :
      A[i][j] = "0"


for j in range(W) :
  wcnt = 0
  for i in range(H) :
    if A[i][j] == "." or A[i][j] == "0":
      wcnt += 1
  if wcnt == H :
    for i in range(H) :
      A[i][j] = "0"


for i in range(H) :
  ans = ""
  for j in range(W) :
    if A[i][j] != "0" :
      ans += A[i][j]
  if ans != "" :
    print (ans)

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

board = []
for i in range(h):
    board.append(input())

hm = []
for i in range(h):
    if board[i] == '.' * w:
        hm.append(i)

wm = []
for i in range(w):
    for j in range(h):
        if board[j][i] != '.':
            break
        if j == h-1:
            wm.append(i)


for i in range(h):
    for j in range(w):
        if i not in hm and j not in wm:
            print(board[i][j], end='')
    if i not in hm:
        print()

Solution (Python):
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


H, W = list(map(int, sys.stdin.buffer.readline().split()))
S = [list(sys.stdin.buffer.readline().decode().rstrip()) for _ in range(H)]

S = np.array(S, dtype='U1')
ans = []
for s in S:
    if '
        ans.append(s)
S = np.array(ans, dtype='U1')
ans = []
for s in S.T:
    if '
        ans.append(s)
ans = np.array(ans, dtype='U1').T
for r in ans:
    print(''.join(r))

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

a = [x for x in a if "

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

a = list(zip(*aT))

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

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

Solution (Python):
h,w=map(int,input().split())
a,c=[],[]
for i in range(h):
    a.append(input())
for i in range(w):
    b=0
    for j in range(h):
        if a[j][i]=='
            b=1
    c.append(b)
for i in range(h):
    if a[i]=='.'*w:
        continue
    for j in range(w):
        if c[j]==1:
            print(a[i][j],end='')
    print('')

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

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

import numpy as np
change_h=0
change_w=w
ans=[]
for i in range(h):
    if l[i].count('.')!=w:
        ans+=[l[i][:]]
        change_h+=1
l_count=[]
for i in range(w):
    count=0
    for j in range(h):
        if l[j][i]=='.':
            count+=1
    
    if count==h:
        l_count+=[i]
    
l_count=sorted(l_count,reverse=True)
for i in l_count:
    ans=np.delete(ans,i,axis=1)
    


for i in range(change_h):
    print(*ans[i],sep='')

Solution (Python):


(row_count, col_count) = [int(i) for i in input().rstrip().split(" ")]

def shrink_col(map):
    new_map = [[] for i in range(len(map))]
    for i in range(col_count):
        all_space = True
        for j in range(len(map)):
            if map[j][i] == '
                all_space = False
                break
        if not all_space:
            for j in range(len(map)):
                new_map[j].append(map[j][i])
    return new_map

def shrink_row(map):
    new_map = []
    for i in range(row_count):
        if len([j for j in map[i] if j == "
            new_map.append(map[i])
    return new_map


map = [input().rstrip() for i in range(row_count)]
map = shrink_row(map)
map = shrink_col(map)

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

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

A = []
for i in range(h):
    s = list(input())
    if len(set(s)) == 1 and s[0] == ".":
        continue
    else:
        A.append(s)
B = A
c = 0
for i in range(w):
    s = []
    for j in range(len(A)):
        s.append(A[j][i])
    if len(set(s)) == 1 and s[0] == '.':
        B = np.delete(B, i-c, 1)
        c += 1


for i in B:
    a = ""
    for j in i:
        a += j
    print(a)

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

grid = []

for _ in range(H):
    grid.append(input())

Hx = [ (True if '
Wx = [ (True if '

for i in range(H):
    flag = False
    for j in range(W):
        if(Hx[i] and Wx[j]):
            flag = True
            print(grid[i][j], sep='', end='')
    if flag:
        print()

Solution (Python):
H,W = map(int,input().split())
s=[list(input()) for i in range(H)]
def ts(s):
  ss=[]
  for i in range(len(s)):
    if s[i] != ["."]*len(s[i]):
      ss.append(s[i])
  return ss
sH = ts(s)
sH = list(map(list,zip(*sH)))
sW = ts(sH)
sW = list(map(list,zip(*sW)))
for i in range(len(sW)):
  print("".join(sW[i]))

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

for i in range(h):
    if ''.join(a[i-tmp]) == '.'*w:
        del a[i-tmp]
        tmp += 1

for i in range(w):
    lst = []
    for j in range(h-tmp):
        lst.append(a[j][i-cnt])
    if ''.join(lst)=='.'*(h-tmp):
        for k in range(h-tmp):
            del a[k][i-cnt]
        cnt += 1

for i in range(h-tmp):
    print(''.join(a[i]))

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

memo = []

for i in range(h):
    if ls_a[i] != ["."] * w:
        memo.append(ls_a[i])

ls = [["" for _ in range(len(memo))] for _ in range(w)]

for i in range(w):
    for j in range(len(memo)):
        ls[i][j] = memo[j][i]

memo = []

for i in range(w):
    if ls[i] != ["."] * len(ls[i]):
        memo.append(ls[i])

ans = [["" for _ in range(len(memo))] for _ in range(len(memo[0]))]

for i in range(len(memo[0])):
    for j in range(len(memo)):
        ans[i][j] = memo[j][i]


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

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

for i in range(H):
	mas.append(list(map(str, input())))
	
for i in range(H):
	flg = 1
	for j in range(W):
		if mas[i][j] == "
			flg = 0
			break
	if flg:
		cut_h.append(i)
		
for i in range(W):
	flg = 1
	for j in range(H):
		if mas[j][i] == "
			flg = 0
			break
	if flg:
		cut_w.append(i)
		
for i in range(H):
	flg = 1
	for j in range(W):
		if i in cut_h:
			flg = 0
			continue
		if j in cut_w: continue
		print(mas[i][j], end = "")
	if flg:
		print()

Solution (Python):
h, w = [int(n) for n in input().split()]
grid = [input() for _ in range(h)]
row_hashs = set()
column_hashs = set()

for i, row in enumerate(grid):
    for j, ch in enumerate(row):
        if ch == '
            row_hashs.add(i)
            column_hashs.add(j)

new_grid = []

for i, row in enumerate(grid):
    if i not in row_hashs:
        continue
    new_grid.append([])
    for j, ch in enumerate(row):
        if j not in column_hashs:
            continue
        new_grid[-1].append(ch)
    new_grid[-1] = "".join(new_grid[-1])

print("\n".join(new_grid))

Solution (Python):
hori_verti = input().split()
horisontal = int(hori_verti[0])
vertical = int(hori_verti[1])
input_grid = [input() for element in range(horisontal)]

remove_yoko_list = set()
remove_tate_list = set()

def scan(grid_verti_list):
  for ele in grid_verti_list:
    if ele != '.':
      return False
  return True

def scan_column():
  for tate in range(vertical):
    row = []
    for yoko in range(horisontal):
      row.append(input_grid[yoko][tate])
    if scan(row):
      remove_tate_list.add(tate)      

for hori_num in range(horisontal):
  grid_verti_list = input_grid[hori_num]
  if scan(list(grid_verti_list)):
    remove_yoko_list.add(hori_num)
    
scan_column()

res = []
for x in range(horisontal):
  keep = []
  if x in remove_yoko_list:
    continue
  for (y, letter) in enumerate(input_grid[x]):
    if y in remove_tate_list:
      continue
    keep.append(letter)
  res.append(keep)
      
result = []  
for str in res:
  new_line_list = ''.join(str)
  result.append(new_line_list)

if(len(result) == 0):
  print('\n'.join(input_grid))
else:
  print('\n'.join(result))

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

for i in range(h):
    if "

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

for i in range(h):
    for j in range(w):
        if i not in lsti and j not in lstj:
            print(a[i][j],end = "")
    else:
        if i not in lsti:
            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):
import sys
input = sys.stdin.readline
H, W = [int(x) for x in input().split()]
a = []
for _ in range(H):
    a.append(list(input().rstrip()))
import numpy as np
a = np.array(a, np.object)
a = a.T
retsu = []
gyou = []
for i in range(W):
    if "
        retsu.append(i)
a = a.T
for i in range(H):
    if "
        gyou.append(i)
a = np.delete(a, retsu, 1)
a = np.delete(a, gyou, 0)
for j in a:
    j = list(j)
    print("".join(j))

Solution (Python):
h,w=map(int,input().split())
a=[]
for _ in [0]*h:
    ai=list(input())
    
    if "
        a.append(ai)
t=[]
for wi in zip(*a):
    if "
        t.append(wi)
for ans in zip(*t):
    print("".join(ans))

Solution (Python):
h, w = [int(n) for n in input().split()]
grid = [input() for _ in range(h)]
row_hashs = set()
column_hashs = set()

for i, row in enumerate(grid):
    for j, ch in enumerate(row):
        if ch == '
            row_hashs.add(i)
            column_hashs.add(j)

new_grid = []

for i, row in enumerate(grid):
    if i not in row_hashs:
        continue
    new_grid.append([])
    for j, ch in enumerate(row):
        if j not in column_hashs:
            continue
        new_grid[-1].append(ch)
    new_grid[-1] = "".join(new_grid[-1])


print("\n".join(new_grid))

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

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

row = []
column = []

for i in range(len(A)):
        for j in range(len(A[i])):
                if A[i][j] == "
                        row.append(i)
                        break

for i in range(W):
        for j in range(len(A)):
                if A[j][i] == "
                        column.append(i)
                        break


for i in range(len(A)):
        flag = True
        for j in range(len(A[i])):
                if i in row:
                        if j in column:
                                print(A[i][j], end = "")
                else:
                        flag = False
                        continue
        if flag:
                print("")

Solution (Python):
def main():
    H, W = [int(i) for i in input().split()]
    grid = [list(input()) for _ in range(H)]
    grid = [l for l in grid if "
    grid = list(zip(*grid))
    grid = [l for l in grid if "
    grid = ["".join(l) for l in zip(*grid)]
    print(*grid, sep="\n")


if __name__ == "__main__":
    main()

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):
a,b = [int(i) for i in input().split()]
l = [input() for _ in range(a)]
skip_num = []

for i in range(b):
    key_set = set()
    for j in range(a):
        key_set |= set(l[j][i])
    if key_set == set('.'):
        skip_num.append(i)
        

ans = [[] for _ in range(a)]       
for k in range(a):
    if set(l[k]) ==  set('.'):
        pass
    else:
        for i in range(b):
            if i in skip_num :
                pass
            else:
                ans[k].append(l[k][i])
                

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

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

remove = "." * W
A = []
for i in range(H):
    a = input()
    if a != remove:
        A.append(list(a))

remove_list = []

for i in range(W):
    if A[0][i] == ".":
        aa = A[0][i]
        flag = 0
        for a in A:
            if aa != a[i]:
                flag = 1
                break
        if flag == 0:
            remove_list.append(i)



for a in A:
    print_list = []
    for idx, a_ in enumerate(a):
        if idx not in remove_list:
            print_list.append(a_)
    print("".join(print_list))