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

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

for i in range(h):
    s = a[i*w:-~i*w]
    if s != '.' * w:
        b += s

nh = len(b) // w
for j in range(w):
    s = b[j::w]
    if s != '.' * nh:
        c += s

nw = len(c) // nh
for i in range(nh):
    print(c[i::nh])

Solution (Python):

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

rows = []
columns = []

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

for i in range(h):
    if a[i].count('
        rows.append(i)

for i in range(h):
    tmp = ''
    if i not in rows:
        for j in range(w):
            if j not in columns:
                tmp += a[i][j]
        print(tmp)

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

grid = [a for a in grid if '

grid = list(zip(*[a for a in zip(*grid) if '
for a in grid:
    print(''.join(a))

Solution (Python):
H, W = map(int,input().split())
A = []
for _ in range(H):
    A.append(list(input()))
col = []
row = []
for i in range(H):
    if not '
        row.append(i)
for i in range(W):
    flag = 1
    for j in range(H):
        if '
            flag = 0
    if flag:
        col.append(i)
for i in range(H):
    if i in row:
        continue
    for j in range(W):
        if j in col:
            continue
        print(A[i][j], end='')
    print()

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

A=[0]*H
i=0
while i<H:
    A[i]=list(input())
    i+=1

B=[]
for i in A:
    if '
        B.append(i)

j=W-1
while j>=0:
    if all(i[j]=='.' for i in B):
        k=0
        while k<len(B):
            B[k].pop(j)
            k+=1
    j-=1




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

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

MAP=  [[0 for i in range(W)] for i in range(H)]

HLIST=[0 for i in range(H)]
WLIST=[0 for i in range(W)]

for h in range(H):
    L=list(input())
    MAP[h]=L
    for w in range(W):
        if(MAP[h][w]=="
            HLIST[h]+=1
            WLIST[w]+=1
for h in range(H):
    if(HLIST[h]!=0):
        for w in range(W):
            if(WLIST[w]!=0):
                if(MAP[h][w]=="
                    print("
                else:
                    print(".",end="")
        print("")

Solution (Python):
h,w=map(int,input().split())
a=[]
for _ in range(h):
    ai = input()
    if '
        a.append(ai)
ans=['']*len(a)
for i in range(w):
    if sum([a[j][i]=='
        continue
    for j in range(len(a)):
        ans[j]+=a[j][i]
for ansi in ans:
    print(ansi)

Solution (Python):
H, W = map(int, input().split())
a = []
for i in range(H):
    b = input()
    a.append(b)
b = []
flag = 0
for i in range(H):
    flag = 0
    for j in range(W):
        if a[i][j] == '
            flag = 1
    if flag == 1:
        d = [1 for i in range(W)]
        b.append(d)
    else:
        d = [0 for i in range(W)]
        b.append(d)
for i in range(W):
    flag = 0
    for j in range(H):
        if a[j][i] == '
            flag = 1
    if flag == 0:
        for j in range(H):
            b[j][i] = 0

for i in range(H):
    flag = 0
    for j in range(W):
        if b[i][j] == 1:
            print(a[i][j], end = "")
            flag = 1
        if flag == 1 and j == W - 1:
            print("")

Solution (Python):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

H, W = nm()
a = [list(ns()) for _ in range(H)]

def compress(a):
    out = []
    for line in a:
        if '
            out.append(line)
    return out

temp = compress(a)
temp2 = compress([list(i) for i in zip(*temp)])
ans = [list(i) for i in zip(*temp2)]

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

Solution (Python):
def resolve():
    h,w=map(int,input().split())
    mass = []
    length=0
    for i in range(h):
        a=list(input())
        if "
            mass.append(a)
            length+=1
    for i in reversed(range(w)):
        total=0
        for j in range(length):
            if mass[j][i]==".":
                total+=1
        if total==length:
            for j in range(length):
                del mass[j][i]
    for i in range(length):
        print("".join(mass[i]))

resolve()

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

A = [[a for a in input()] for _ in range(H)]
flag = True
while flag:
    flag = False
    
    rm = []
    for i, a in enumerate(A):
        if '
            rm.append(i)
    if len(rm) > 0:
        flag = True
        A = [a for i, a in enumerate(A) if i not in rm]
    
    rm = []
    A = list(zip(*A))
    for i, a in enumerate(A):
        if '
            rm.append(i)
    if len(rm) > 0:
        flag = True
        A = [a for i, a in enumerate(A) if i not in rm]
    A = list(zip(*A))

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

Solution (Python):
H,W = map(int,(input().split()))
a = [[] for _ in range(H)]
b = []
deh = []
for i in range(H):
    a[i] = list(input())
    
for i in range(H):
    if a[i] != ["."]*W:
        b.append(a[i])

for i in range(W)[::-1]:
    c = 0
    for j in range(len(b)):
        if b[j][i] == ".":
            c += 1
    if c == len(b):
        for j in range(len(b)):
            b[j].pop(i)

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

Solution (Python):
h,w = map(int,input().split())
f = [input()for i in range(h)]
H = []
W = []
for i in range(h):
    ok = True
    for j  in range(w):
        if f[i][j] == '
            ok = False
            break
    if ok:H.append(i)
for i in range(w):
    ok = True
    for j in range(h):
        if f[j][i] == '
            ok = False
            break
    if ok:W.append(i)
nf = []
for i in range(h):
    p = []
    for j in range(w):
        if  i in H or j in W:continue
        p.append(f[i][j])
        
    if len(p) > 0:nf.append(p)
for i in range(len(nf)):
    print("".join(nf[i]))

Solution (Python):
h,w=map(int,input().split())
a=[[0 for j in range(w)] for i in range(h)]
for i in range(h):
  s=input()
  for j in range(w):
    if s[j]==".":
      a[i][j]=0
    else:
      a[i][j]=1
H=[]
for i in range(h):
  if sum(a[i])==0:
    H.append(i)
a2=[[0 for j in range(w)] for i in range(h-len(H))]
key=0
for _ in range(h):
  if _ in H:
    continue
  else:
    for j in range(w):
      a2[key][j]=a[_][j]
    key+=1
Q=[]
S=[0]*w
for j in range(w):
  for i in range(h-len(H)):
    S[j]+=a2[i][j]
for j in range(w):
  if S[j]==0:
    Q.append(j)
key=0


a3=[[0 for j in range(w-len(Q))] for i in range(h-len(H))]
for j in range(w):
  if j in Q:
    continue
  elif j not in Q:
    for i in range(h-len(H)):
      a3[i][key]=a2[i][j]
    key+=1

for i in range(h-len(H)):
  for j in range(w-len(Q)):
    a3[i][j]=str(a3[i][j])
    if a3[i][j]=="0":
      a3[i][j]="."
    elif a3[i][j]=="1":
      a3[i][j]="
ans=[""]*(h-len(H))
for i in range(h-len(H)):
  for j in range(w-len(Q)):
    ans[i]+=a3[i][j]
  print(ans[i])

Solution (Python):
h,w = map(int,input().split())
a=[]
for i in range(h):
    b = input()
    f = False
    for j in range(len(b)):
        if b[j] == '
            f = True
    if f:
        a.append(list(b))

f = True
cnt = 0
for i in range(len(a[0])):
    for j in range(len(a)):
        if(a[j][i-cnt] == '
            f = False
    if f:
        for j in range(len(a)):
            del a[j][i-cnt]
        cnt += 1
    f = True

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

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

n = len(a)
a = [list(x) for x in zip(*a)] 
x = 0 

for i in range(w):
    if a[i-x].count(".") == n:
        a.pop(i-x)
        x += 1

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

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

Solution (Python):
h, w = map(int, input().split())
T = [input() for _ in range(h)]
flagRow = [0] * h
flagColumn = [0] * w

for i in range(h):
    for j in range(w):
        if T[i][j] == "
            flagRow[i] = 1
            flagColumn[j] = 1

for i in range(h):
    if flagRow[i] == 1:
        for j in range(w):
            if flagColumn[j] == 1:
                print(T[i][j], end = "")
        print("")

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

Solution (Python):
H,W = map(int,input().split())
a = []
for i in range(H):
    x = list(input())
    if '
        a.append(x)
def trans(a):
    x = [i for i in zip(*a)]
    return x
at = trans(a)
an = []
for i in at:
    if '
        an.append(i)
ans = trans(an)
for i in ans:
    print(*i,sep = '')

Solution (Python):
h, w, *d = open(0).read().split()
h, w = int(h), int(w)
d = [i for i in d if "
d = zip(*[j for j in zip(*d) if "
print(*["".join(p) for p in d], sep="\n")

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

for i in range(H):
    a.append(input())

row = [i for i in range(H)]
column = [i for i in range(W)]

row_delete = []
column_delete = []

for i in range(H):
    flag_delete = True
    for j in range(W):
        if a[i][j] == "
            flag_delete = False
            break
    if flag_delete == True:
        row_delete.append(i)

for i in range(W):
    flag_delete = True
    for j in range(H):
        if a[j][i] == "
            flag_delete = False
            break
    if flag_delete == True:
        column_delete.append(i)


for i in row_delete:
    row.remove(i)

for i in column_delete:
    column.remove(i)

ans = [["" for _ in range(len(column))] for _ in range(len(row))]

count_row = 0
for i in row:
    count_column = 0
    for j in column:
        ans[count_row][count_column] = a[i][j]
        count_column += 1
    count_row += 1

for i in range(len(ans)):
    print("".join(ans[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 = [''] * 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 = [input() for _ in range(h)]

remove_a = []
for i in range(h):
    if '
        remove_a.append(list(a[i]))

n = len(remove_a)
l = []
for i in range(w):
    s = ''
    for j in range(n):
        s += remove_a[j][i]
    if '
        l.append(list(s))

ans = ''
for i in range(len(l[0])):
    s = ''
    for j in range(len(l)):
        s += l[j][i]
    ans += s
    if i != len(l[0])-1:
        ans += '\n'
print(ans)

Solution (Python):

import fractions


h, w = map(int,input().split())
h_list = []
w_list = []
F = []
for i in range(h):
    l = list(input())
    F.append(l)
    if list(set(l)) == ['.']:
        w_list.append(i)
        
for i in range(w):
    cnt = 0
    for j in range(h):
        if F[j][i] == '.':
            cnt += 1
        else:
            break
    if cnt == h:
        h_list.append(i)
A = []

for i in range(h):
    if i not in w_list:
        l = []
        for j in range(w):
            if j not in h_list:
                
                l.append(F[i][j])
        
        A.append(l)

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

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

deleted_w = []
for i in range(H):
  if(all(j == "." for j in grid[i])):
    deleted_w.append(i)

deleted_h = []
for i in range(W):
  line = [ grid[k][i] for k in range(H)]
  if(all(j == "." for j in line)):
    deleted_h.append(i)

for i in range(H):
  if(i in deleted_w):
    continue
  for j in range(W):
    if(j in deleted_h):
      continue
    else:
      print(grid[i][j], end="")
  print("")

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

for i in range(w):
    t = True
    length = len(a)
    for j in range(length):
        if a[j][i] != '.':
            t = False
            break
    if t:
        for k in a:
            k[i] = 'D'


for i in a:
    for j in i:
        if j != 'D':
            print(j, end='')

    print()

Solution (Python):
H, W = map(int, input().split())
S = [input() for i in range(H)]
h, w = [True for _ in range(H)], [True for _ in range(W)]
for i in range(H):
  cnt = 0
  for j in range(W):
    if S[i][j] == '.':
      cnt += 1
  if cnt == W:
    h[i] = False
for i in range(W):
  cnt = 0
  for j in range(H):
    if S[j][i] == '.':
      cnt += 1
  if cnt == H:
    w[i] = False
for i in range(H):
  if h[i]:
    T = ""
    for j in range(W):
      if w[j]:
        T = T[:] + S[i][j]
    print(T)

Solution (Python):
h, w = map(int, input().split())
grid = []
for i in range(h):
    a = input()
    x = [j for j in a]
    grid.append(x)
grid_2 = []
for j in grid:
    if '
        grid_2.append(j)

rotate = []
for i in range(w):
    r = [row[i] for row in grid_2]
    rotate.append(r)

rotate_2 = []
for j in rotate:
    if "
        rotate_2.append(j)

re_rorate = []
z = len(rotate_2[0])
for i in range(z):
    r_r = [row[i] for row in rotate_2]
    re_rorate.append(r_r)

for i in range(z):
    y = re_rorate[i]
    j ="".join(y)    
    print(j)

Solution (Python):
def b_grid_compression():
    import numpy as np
    H, W = [int(i) for i in input().split()]
    A = np.array([list(input()) for _ in range(H)])

    for i in (1, -1):
        A = A[np.any(A == '
        A = np.rot90(A, i)
    return '\n'.join([''.join(row) for row in A])

print(b_grid_compression())

Solution (Python):

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

l=[]
for i in range(H):
  x=input()
  
  if x!='.'*W:
    l.append(x)

rm=[]
for i in range(W):
  
  f=True
  for j in range(len(l)):
    if l[j][i]=='
      f=False

  
  if f:
    rm.append(i)

a=[]
for x in l:
  for i in rm[::-1]:
    x=x[:i]+x[i+1:]
  a.append(''.join(x))


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

Solution (Python):
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

h, w = na()
a = ncl(h)

for i in range(h):
    flag = True
    for j in range(w):
        if a[i][j] != '.':
            flag = False
    
    if flag:
        for j in range(w):
            a[i][j] = '$'

for j in range(w):
    flag = True
    for i in range(h):
        if a[i][j] != '.' and a[i][j] != '$':
            flag = False
    
    if flag:
        for i in range(h):
            a[i][j] = '$'

ans = []
for i in range(h):
    ans.append([])
    for j in range(w):
        if a[i][j] != '$':
            ans[i].append(a[i][j])

for i in range(len(ans)):
    if len(ans[i]) != 0:
        print(*ans[i], sep="")

Solution (Python):
def main():
    H,W = map(int,input().split())
    strings = []

    for h in range(H):
        inp = input()
        if not "
            continue
        strings.append(inp)


    
    
    
    

    delete_row = [False] * W
    for i in range(W):
        if all([string[i]=="." for string in strings]):
            delete_row[i] =True


    
    new_strings = []
    for string in strings:
        temp_s = ""
        for i,c in enumerate(string):
            if not delete_row[i]:
                temp_s = temp_s + c
        new_strings.append(temp_s)
    


    for string in new_strings:
        print(string)











if __name__ == '__main__':
    main()

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


def main():
    H, W = [int(x) for x in input().split()]
    A = [input().strip() for _ in range(H)]

    ansh = []
    for i, a in enumerate(A):
        if a.count("
            ansh.append(i)

    answ = []
    for i, a in enumerate(zip(*A)):
        if a.count("
            answ.append(i)

    for j in range(H):
        if j in ansh:
            continue
        for i in range(W):
            if i in answ:
                continue
            else:
                print(A[j][i], end="")
        print("")

    
    
    


if __name__ == '__main__':
    main()

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

grid = [i for i in grid if i.count('
c = []
for j in range(w):
    for i in range(len(grid)):
        if grid[i][j]=='
            break
    else:
        c.append(j)
for row in grid:
    tmp = ''
    s = 0
    for i in c:
        tmp += row[s:i]
        s = i+1
    tmp += row[s:]
    print(tmp)

Solution (Python):
import sys
from collections import *
import heapq
import math
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

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

while 1:
    flag=1
    lst=[]
    for i in range(h):
        tmp=a[i][0]
        if tmp=="
            continue
        for j in range(w):
            if tmp==a[i][j]:
                continue
            else:
                break
        else:
            lst.append(i)
            flag=0
    for i in range(len(lst)):
        del a[lst[-1-i]]
        h-=1

    lst=[]
    for i in range(w):
        tmp=a[0][i]
        if tmp=="
            continue
        for j in range(h):
            if tmp==a[j][i]:
                continue
            else:
                break
        else:
            lst.append(i)
            flag=0
    
    
    for i in range(len(lst)):
        for j in range(h):
            a[j]=a[j][:lst[-1-i]] + a[j][lst[-1-i]+1:]
    w-=len(lst)
    if flag:
        break
for i in a:
    print(i)

Solution (Python):
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    h, w = MII()
    aa = [IS() for _ in range(h)]
    aa_w = [a for a in aa if '.'*w != a]
    aa_w_t = [''.join(list(a)) for a in zip(*aa_w)]
    w = len(aa_w_t[0])
    aa_w = [a for a in aa_w_t if '.'*w != a]
    aa_w_t = [''.join(list(a)) for a in zip(*aa_w)]
    aa_w_t = [''.join(list(a)) for a in zip(*aa_w)]
    for a in aa_w_t: print(a)


if __name__ == '__main__':
    main()

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

for i in range(h):
    x = input()
    
    if x.count(".") != w:
        x = list(x)
        X.append(x)
        
h = len(X)

for i in range(w):
    wrong = 0
    for j in range(h):
        if X[j][i] == ".":
            wrong += 1
            
        if wrong == h:
            for k in range(h):
                X[k][i] = "*"
                
for i in range(h):
    print(("".join(X[i])).replace("*",""))

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

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

w90 = []
for i in range(w):
    x = ""
    for j in range(len(a)):
        x += a[j][i]

    if "
        w90.append(x)

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

Solution (Python):
def solve():

    H, W = [int(i) for i in input().split()]
    alist = [input() for i in range(H)]

    cols = [False]*H
    rows = [False]*W

    for i in range(H):
        for j in range(W):
            if alist[i][j] == '
                cols[i] = True
                rows[j] = True

    for i in range(H):
        if cols[i]:
            for j in range(W):
                if rows[j]:
                    print(alist[i][j], end="")

            print()


if __name__ == "__main__":
    solve()

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 = [input() for i in range(h)]
ans = []
memo_x = []
memo_y = []
for i in range(h):
    cnt = 0
    for j in range(w):
        if a[i][j] == '.':
            cnt += 1
    if cnt == w:
        memo_x.append(i)
for i in range(w):
    cnt = 0
    for j in range(h):
        if a[j][i] == '.':
            cnt += 1
    if cnt == h:
        memo_y.append(i)
for i in range(h):
    if i not in memo_x:
        b = ''
        for j in range(w):
            if j not in memo_y:
                b += a[i][j]
        ans.append(b)
for i in range(len(ans)):
    print(ans[i])

Solution (Python):
H, W = map(int, input().split())
l = []
temp_l = [0]*H
for i in range(H):
    l.append(list(str(input())))

for i in range(H):
    flag = 1
    for j in range(W):
        if l[i][j] == '
            flag = 0
    if flag == 1:
        temp_l[i] = 1
        for j in range(W):
            l[i][j] = 0

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


for i in range(H):
    for j in range(W):
        if temp_l[i] == 0:
            if not l[i][j] == 0:
                print(l[i][j], end='')
    if temp_l[i] == 0:
        print('')

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

delete_column = [True]*w
delete_row = [True]*h
for i in range(h):
  for j in range(w):
    if a[i][j] == '
      delete_column[j] = False
      delete_row[i] = False
for i in range(h):
  if not delete_row[i]:
    ans = ''
    for j in range(w):
    	if not delete_column[j]:
          ans += a[i][j]
    print(ans)

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

masu=[]
for i in range(h):
    gyou=list(input())
    if gyou!=["."]*w:
        masu.append(gyou)
        
def rotate(masu):
    m=len(masu)
    n=len(masu[0])
    rotatemasu=[]
    for i in range(n):
        gyou=[]
        for j in range(m):
                gyou.append(masu[m-j-1][i])
        if gyou!=["."]*m:
            rotatemasu.append("".join(gyou))
        
    return rotatemasu
for i in range(4):
    masu=rotate(masu)
for i in masu:
    print(i)

Solution (Python):
p,q= input().split()
a,b =(int(p), int(q))
a_list = []
count_row = 0
b_h ='.'*b

for i in range(a):
    c = input()
    
    if c == b_h:
        count_row+=1
    else:
        a_list.append(c)

ans_list=[]
for i in range(b):
    count_clm = 0
    
    for j in range(a-count_row):
        if a_list[j][i] == '.':
            count_clm+=1
    
    
        if count_clm == (a-count_row):        
            ans_list.append(i)



for j in range(a-count_row):
    total=''
    for i in range(b):
        if i in ans_list:
            ds = 0
        else:
            total +=a_list[j][i]
            
    print(total)

Solution (Python):
def solve():

    H, W = [int(i) for i in input().split()]
    alist = [input() for i in range(H)]

    cols = [False]*H
    rows = [False]*W

    for i in range(H):
        for j in range(W):
            if alist[i][j] == '
                cols[i] = True
                rows[j] = True

    for i in range(H):
        if cols[i]:
            for j in range(W):
                if rows[j]:
                    print(alist[i][j], end="")
            print()


if __name__ == "__main__":
    solve()

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


for a in list(zip(*A)):
    if("

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

Solution (Python):
H,W=map(int,input().split())
A=[]
for _ in range(H):
    a=list(input())
    if("
        A.append(a)
answer=[]
for i in range(W):
    tmp=[]
    hantei=True
    for a in A:
        if(a[i]=="
            hantei=False
        tmp.append(a[i])
    if(hantei==False):
        answer.append(tmp)

result = list(zip(*answer))
for r in result:
    print("".join(r))

Solution (Python):
h,w=map(int,input().split())
a=[list(input()) for _ in [0]*h ]
b=[[i[j] for i in a] for j in range(w)]
H,W=[],[]
for i in range(h):
  if a[i]==['.']*w:
    H.append(i)
for j in range(w):
  if b[j]==['.']*h:
    W.append(j)
a=[''.join([a[i][j] if not j in W else '' for j in range(w)]) if not i in H else 0 for i in range(h)]
for i in range(h):
  if type(a[i])!=int:
    print(a[i])

Solution (Python):
h,w=map(int,input().split())
s=[input() for i in range(h)]
s=[s_x for s_x in s if '
s=[s_y for s_y in zip(*s) if '
for ss in zip(*s):
    print(''.join(ss))

Solution (Python):
def solve():

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

    cols = [False] * H
    rows = [False] * W

    for i in range(H):
        for j in range(W):
            if alist[i][j] == '
                cols[i] = True
                rows[j] = True

    for i in range(H):
        if cols[i]:
            for j in range(W):
                if rows[j]:
                    print(alist[i][j], end="")

            print()


if __name__ == "__main__":
    solve()

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


B = [False] * H
C = [False] * W

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

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

Solution (Python):
inputs = [s.strip() for s in open(0).readlines()]
import numpy as np
class Grid():
    def __init__(self, grid, w=0, h=0, function=lambda x: x):
        self.w = w = w if w else len(grid[0])
        self.h = h = h if h else len(grid)
        dtype = type(function(grid[0][0]))
        self.grid = np.empty((h, w), dtype=dtype)
        for i, rows in zip(range(h), grid):
            for j, val in zip(range(w), rows):
                self.grid[i][j] = function(val)
    
    def is_valid_x(self, x):
        return 0 <= x < self.w
    def is_valid_y(self, y):
        return 0 <= y < self.h
    def is_valid_xy(self, x, y):
        return self.is_valid_x(x) and self.is_valid_y(y) 
    
    def __iter__(self):
        return iter(self.grid)
    def __repr__(self):
        return '\n'.join([' '.join(map(str, rows)) for rows in self.grid])
    def __getitem__(self, x):
        return self.grid[x]
    def __setitem__(self, x, val):
        self.grid[x] = val

h, w = map(int, inputs[0].split())
grid = Grid([s.strip() for s in inputs[1:]]).grid
grid = grid[:, ~np.all(grid == '.', axis=0)]
grid = grid[~np.all(grid == '.', axis=1), :]
print(*[''.join(map(str, row)) for row in grid], sep='\n')

Solution (Python):

def main():
    H, W = map(int, input().split())
    grid = []
    for _ in range(H):
        row = list(input())
        grid.append(row)

    for i in reversed(range(H)):
        if not "
            del grid[i]
            H -= 1

    for j in reversed(range(W)):
        flag = True
        for i in reversed(range(H)):
            if grid[i][j] == "
                flag = False
                break
        if flag == True:
            for i in range(H):
                del grid[i][j]
    for row in grid:
        print("".join(row))

if __name__ == "__main__":
    main()

Solution (Python):
h, w = map(int, input().split())
h_w_list = [list(input()) for i in range(h)]
h_li = []
w_li = []
for i in range(h):
    if "
        h_li.append(i)
for j in range(w):
    if "
        w_li.append(j)
for i in h_li:
    for j in w_li:
        print(h_w_list[i][j], end="")
    print()

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

cnt=0
while cnt<H:
    if a[cnt]=='.'*W:
        H-=1
        del a[cnt]
    else:
        cnt+=1

cnt=0
while cnt<W:
    for s in a:
        if s[cnt]=='
            cnt+=1
            break
        elif s==a[H-1]:
            W-=1
            for i in range(H):
                a[i]=a[i][:cnt]+a[i][cnt+1:]

            
for s in a:
    print(s)

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

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

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