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 f(l,x):
  z=[]
  for i in range(x):
    if set(l[i])!=set('.'):
      z.append(l[i])
  return list(map(list, zip(*z)))
h,w=map(int,input().split())
a=[list(input()) for _ in range(h)]
l=f(f(a,h),w)
for i in range(len(l)):
  print(''.join(l[i]))

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

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

a = [i for i in zip(*a)]
a = [i for i in a if "

a = [i for i in zip(*a)]
a = [i for i in a if "

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

Solution (Python):
h, w = [int(i) for i in input().split()]
a = []
d = []
h_new = 0
for i in range(h):
  b = input()
  if "
    a.append(list(b))
    h_new += 1
for i in range(w):
  c = []
  for j in range(h_new):
    c.append(a[j][i])
  if "
    d.append(i)
e = ""
for i in range(h_new):
  for j in range(w):
    if j not in d:
      print(a[i][j],end="")
  print("\n")

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

for i in reversed(range(H)):
  if A[i]==["."]*W:
    A.pop(i)
    
for j in reversed(range(W)):
  flag=0
  for i in range(len(A)):
    if A[i][j]=="
      flag=1
  if flag==0:
    for i in range(len(A)):
      A[i].pop(j)

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

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

B=[]
D=[]

for i in range(H):
  if A[i]!="."*W:
    B.append(list(A[i]))
    
C=[["0" for j in range(len(B))] for i in range(W)]

for i in range(len(B)):
  for j in range(W):
    C[j][i]=B[i][j]

for i in range(W):
  if C[i]!=["."]*len(B):
    D.append(C[i])
   
E=[["0" for j in range(len(D))] for i in range(len(B))]

for i in range(len(D)):
  for j in range(len(B)):
    E[j][i]=D[i][j]
    
for i in range(len(B)):
  print("".join(E[i]))

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

row, col = [False] * H, [False] * W
for i in range(H):
    for j in range(W):
        if a[i][j] == "
            row[i] = 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())
rlist = [] 

for i in range(h):
    olist = list(input()) 
    if olist != ['.']*w:
        rlist.append(olist)


tlist = [0]*w
for j in rlist:
    for k in range(w):
        if j[k] == ('.'):
            tlist[k] += 1


anslist = [[]]
for l in range(w):
    if tlist[l] == len(rlist):
        for m in rlist:
            m[l] = ''

newlist = []
for h in rlist:
    newlist.append(''.join(h))

for n in newlist:
    print(n)

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

a = []
for _ in range(h):
    row = list(input())
    if not all([c == '.' for c in row]):
        a.append(row)

all_whites = []
for j in range(w):
    if all([a[i][j] == '.' for i in range(len(a))]):
        all_whites.append(j)

for row in a:
    removed_row = [row[j] for j in range(w) if j not in all_whites]
    print(''.join(removed_row))

Solution (Python):
H,W=[int(a) for a in input().split(" ")]
tab=[input() for i in range(H)]
tab2=[]
for row in tab:
    if any([a!="." for a in row]):
        tab2.append(row)
tab = []
for column in zip(*tab2):
    if any([a!="." for a in column]):
        tab.append(column)
for row in zip(*tab):
    print("".join(row))

Solution (Python):
h,w=map(int,input().split())
a = [list(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())
a = [input() for _ in range(H)]
a = [i for i in zip(*a) if i.count('
a = ["".join(i) for i in zip(*a) if i.count('
print("\n".join(a))

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

a = [input() for i in range(h)]

bh = [0] * h
bw = [0] * w

for i in range(h):
  for j in range(w):
    if a[i][j] == '
      bh[i] = 1
      bw[j] = 1
      
for i in range(h):
  if bh[i]:
    for j in range(w):
      if bw[j]:
        print(a[i][j], end='')
    print()

Solution (Python):
h,w=map(int,input().split())
a=[input()for _ in range(h)]
b=[]
v=list(map(int,'0'*w))
for i,r in enumerate(a):
  if r=='.'*w:
    b.append(i)
  for j in range(w):
    v[j]+=r[j]=='.'
f=[j for j in range(w)if v[j]==h]
for i,r in enumerate(a):
  if i not in b:
    t=list(map(str,a[i]))
    for j in f:
      t[j]=''
    print(''.join(t))

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

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

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

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

WHITE = '.'
BLACK = '

new_a = []

for i in range(H):
    if BLACK in a[i]:
        new_a.append(a[i])

new_H = len(new_a)
new_W = len(new_a[0])
new_a2 = [[] for i in range(new_H)]

for j in range(new_W):

    has_black = False

    for i in range(new_H):
        if new_a[i][j] == BLACK:
            has_black = True

    if has_black:
        for i in range(new_H):
            new_a2[i].append(new_a[i][j])

for row in new_a2:
    for data in row:
        print(data, end='')
    print('')

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

data = []
for i in range(h):
    data.append([])
    for  j in range(w):
        data[i].append(data_t[i][j])
    
for i in range(h):
    contw=True
    line = ""
    for j in range(w):
        c = data[i][j]
        if c == "
            contw = False
            line+="
        elif c == ".":
            pre = True
            for k in range(h):
                if data[k][j] == "
                    pre = False
            if pre == True:
                for k in range(h):
                    data[k][j] = "_"
            else:
                line+="."
    if contw == False:
        print(line)

Solution (Python):
hw=list(map(int,input().split()))
h=hw[0]
w=hw[1]
a=[[] for i in range(h)]
b=[]
for i in range(h):
    a[i] = list(str(input()))
for i in range(h):
    y=True
    for j in range(w):
        if y and a[i][j]==".":
            y=True
        else:
            y=False
    if not(y):
        b.append(a[i][:])
c=[[] for i in range(len(b))]
e=[0 for i in range(len(b[0]))]
for i in range(len(b[0])):
    t=True
    for j in range(len(b)):
        if t and b[j][i]==".":
            t=True
        else:
            t=False
    e[i]=t
for i in range(len(b)):
    for j in range(len(b[0])):
        if not(e[j]):
            c[i].append(b[i][j])
for i in range(len(c)):
    print("".join(c[i]))

Solution (Python):


H, W = map(int, input().split())
a = []
for _ in range(H):
    tmp = list(input())
    if "
        a.append(tmp)

a_reverse = list(map(list, zip(*a)))
ans = []
for tmp in a_reverse:
    if "
        ans.append(tmp)

ans_list = list(map(list, zip(*ans)))

for tmp_list in ans_list:
    tmp = ""
    for tmp_val in tmp_list:
        tmp += tmp_val
    print(tmp)

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

w_check = [True] * W
for i in range(len(a)):
    for j in range(W):
        if a[i][j] == "
            w_check[j] = False

ans = [[] for i in range(len(a))]
for i in range(len(a)):
    for j in range(W):
        if not w_check[j]:
            ans[i].append(a[i][j])

for i in ans:
    output = ""
    for j in i:
        output += j
    print(output)

Solution (Python):
h,w=map(int,input().split())
t=[list(input()) for _ in range(h)]
for i in range(h):
    t[i]=[(tij=="
rows=[]
columns=[]
for i,ti in enumerate(t):
    if sum(ti)==0:
        rows+=[i]
for j,tj in enumerate(zip(*t)):
    if sum(tj)==0:
        columns+=[j]
nt=[]
for i,ti in enumerate(t):
    if i in rows:continue
    nti=[]
    for j,tij in enumerate(ti):
        if j in columns:continue
        nti+=["
    print(*nti,sep="")

Solution (Python):
import numpy as np
h,w=map(int,input().split())
t=[list(input()) for _ in range(h)]
for i in range(h):
    t[i]=[(tij=="
t=np.array(t,dtype="i2")
rows=[]
columns=[]
for i in range(h):
    if np.sum(t[i])==0:
        rows+=[i]
for j in range(w):
    if np.sum(t[:,j])==0:
        columns+=[j]
t=np.delete(t,rows,0)
t=np.delete(t,columns,1)
for i in range(h-len(rows)):
    print(*["

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

strs = [input() for i in range(h)]

hFlag = []
wFlag = []

for i in range(h):
    if len(strs[i]) == len(strs[i].replace('
        wFlag.append(False)
    else:
        wFlag.append(True)

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

    if flag :
        hFlag.append(True)
    else:
        hFlag.append(False)

for i in range(h):
    if wFlag[i]:
        for j in range(w):
            if hFlag[j]:
                print(strs[i][j], end='')

        print()

Solution (Python):
H,W = map(int,input().split())
A = [[s for s in input()] for i in range (H)]
sumh = 0
h = [False]*H
w = [False]*W
for i in range(H):
    for j in range(W):
         if A[i][j] == '
             h[i] = True
             w[j] = True

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

        print()

Solution (Python):

H, W = map(int, input().split())
A = [[s for s in input()] for i 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())
Map=[]
MAP=[]
Key=[]
cnt=0
import numpy as np

for i in range(H):
    tmp=input()
    if tmp!='.'*W:
        Map.append(tmp)
        
for i in Map:
    MAP.append(list(i))
    
for i in range(W):
    for j in range(len(MAP)):
        if MAP[j][i]=='.':
            cnt+=1
    if cnt==len(Map):
        Key.append(i)
    cnt=0

MAP=np.delete(MAP,Key,1)

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

Solution (Python):
import sys
H,W = map(int, input().strip().split(' '))
lines = [line.strip() for line in sys.stdin if '
lines = [''.join(l) for l in zip(*lines)]  
lines = [line for line in lines if '
lines = [''.join(l) for l in zip(*lines)]
for line in lines:
  print(line)

Solution (Python):
from sys import stdin
import numpy as np

H, W = map(int,input().split())
board = [[str(c) for c in l.strip()] for l in stdin]
np_board = np.array(board)
np_board = np_board[:, np.any(np_board == "
np_board = np_board[np.any(np_board == "

for i in range(np_board.shape[0]):
  for j in range(np_board.shape[1]):
    print(np_board[i][j], end="")
  print("")

Solution (Python):

h, w = list(map(int, input().rstrip().split()))
data = [input().rstrip() for _ in range(h)]
row = [False] * h
col = [False] * w

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

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

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

a=[]
for _ in range(H):
  w = input()
  if w != '.'*W:
    a.append(w)
  else:
    continue

b=[]
for i in range(W):
  c = ""
  for j in range(len(a)):
    c += a[j][i]
  if c != '.'*len(a):
    b.append(c)
  else:
    continue

d=[]
for i in range(len(b[0])):
  e = ""
  for j in range(len(b)):
    e += b[j][i]
  d.append(e)

print('\n'.join(d))

Solution (Python):

import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd
readInt = lambda: int(sys.stdin.readline())
readIntN = lambda: [int(v) for v in sys.stdin.readline().split(' ')]



def main():
    h, w = readIntN()
    a = []
    for _ in range(h):
        s = input()
        if list(set(s)) != ['.']:
            a.append(s)
    r = []
    for i in range(w):
        ll = [s[i] for s in a]
        if len(set(ll)) == 1 and '.' in ll:
            continue
        r.append(ll)

    for j in range(len(r[0])):
        u = [r[i][j] for i in range(len(r))]
        print(''.join(u))

if __name__ == '__main__':
    main()

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

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

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

a = np.array(a)

i = 0
j = 0


while i < len(a):
    if np.sum(a[i,:] == '
        a = np.delete(a, i, 0)
        i -=1
    i +=1

while j < w:
    if np.sum(a[:,j] == '
        a = np.delete(a, j, 1)
        j -= 1
    j += 1
    h, w = a.shape



h, w = a.shape
for i in range(h):
    for j in range(w):
        print(a[i, j], end="")
    print('')

Solution (Python):
h,w=map(int,input().split())
a=[s for s in [input() for i in range(h)] if "
l=[]
for i in range(w):
    if all([a[k][i]=="." for k in range(len(a))]):
        l.append(i)
for i in l[::-1]:
    for j in range(len(a)):
       a[j]=a[j][:i]+a[j][i+1:]
for i in range(len(a)):
    print(a[i])

Solution (Python):
import numpy as np
H,W = map(int,input().split(' '))
X = []
for i in range(H):
  X.append(list(input()))
X = np.array(X)
a = X[:,~np.all(X == '.',axis=0)]
b = a[~np.all(a == '.',axis=1),:]
for i in b:
  print(''.join(i))

Solution (Python):
[H,W] = list(map(int,input().split()))
A = [input() for i in range(H)]
row = []
col = []
for i in range(H):
  all_white = True
  for j in range(W):
    if A[i][j] == "
      all_white = False
  if all_white:
    row.append(i)
for j in range(W):
  all_white = True
  for i in range(H):
    if A[i][j] == "
      all_white = False
  if all_white:
    col.append(j)
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())
grid = []
for i in range(h):
    a = list(input())
    for j in range(w):
        if a[j] == "
            grid.append(a)
            break
        else:
            continue

col = [i for i in range(len(grid[0]))]
for j in range(len(grid[0])):
    for i in range(len(grid)):
        if grid[i][j] == "
            break
    else:
        continue
    col.remove(j)

for g in grid:
    for c in col[::-1]:
        g.pop(c)
    print(*g, sep='')

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

row = [False for i in range(H)]
col = [False for i in range(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] == True:
        for j in range(W):
            if col[j] == True:
                print(a[i][j],end="")
        print()

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

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

data = []
for i in range (H):
    temp = list(input())
    data.append(temp)

data = np.array(data)

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

w_true = []
for j in range (W):
    if (('
        w_true.append(j)

data = np.delete(data,h_true,0)
data = np.delete(data,w_true,1)

for k in range (data.shape[0]):
    print(''.join(data[k]))

Solution (Python):
H, W = map(int,input().split())
a = []
for i in range(H):
    L = list(input())
    a.append(L)
delH,delW = [],[]
for i in range(H):
    if all(a[i][j]=='.' for j in range(W)):
        delH.append(i)
for j in range(W):
    if all(a[i][j]=='.' for i in range(H)):
        delW.append(j)
for i in range(H):
    for j in range(W):
        if i not in delH and j not in delW:
            print(a[i][j], end="")
    if i not in delH:
        print()

Solution (Python):
H, W = map(int, input().rstrip().split())
a = [list(input()) for _ in range(H)]
a_int = []
for i in range(H):
    tmp = [1 if a[i][j] == "
    a_int.append(tmp)
column = []
row = []
for i in range(H):
    if sum(a_int[i])==0:
        row.append(i)
for i in range(W):
    total = 0
    for j in range(H):
        total += a_int[j][i]
    if total == 0:
        column.append(i)
row.reverse()
column.reverse()
for i in row:
    a.pop(i)
for i in column:
    for j in range(len(a)):
        a[j].pop(i)
for S in a:
    print(*S, sep ="")

Solution (Python):
H,W=map(int,input().split())
c=[]
for i in range(H):
  ci=input()
  if ci=="."*W:
    continue
  c.append(ci+"
l=len(c)
k=[True]*(W+1)
for i in range(l):
  for j in range(W,-1,-1):
    k[j]=k[j] and (c[i][j]==".")

for i in range(l):
  for j in range(W,-1,-1):
    if k[j]:
      c[i]=c[i][0:j]+c[i][j+1:]
for i in range(l):
  print(c[i][:-1])

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

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

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

Solution (Python):

import sys
import copy
import collections
from bisect import bisect_left
	
def main():
	H, W = map(int, input().split())
	chk = "." * W
	A = []
	for _ in range(H):
		tmp = input()
		if tmp != chk:
			A.append(list(tmp))
		else:
			H -= 1
			
	del_list = []
	for i in range(W):
		del_ok = True
		for j in range(H):
			if "." != A[j][i]:
				del_ok = False
				break
		if del_ok == True:
			del_list.append(i)
			
	ans = []
	line = ""
	for i in range(H):
		line = ""
		for j in range(W):
			if j in del_list:
				continue
			line += A[i][j]
		print(line)
	
if __name__ == "__main__":
	main()

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

tate = set(range(H))
yoko = set(range(W))

for i in range(H):
    for j in range(W):
        if A[i][j] == "
            break
    else:
        tate.remove(i)

for i in range(W):
    for j in range(H):
        if A[j][i] == "
            break
    else:
        yoko.remove(i)

B=[[A[i][j] for i in tate] for j in yoko]
C=[""]*(len(list(tate)))

for i in range(len(list(tate))):
    for j in range(len(list(yoko))):
        C[i] += B[j][i]

for i in range(len(list(tate))):
    print(C[i])

Solution (Python):
import numpy as np

H,W = map(int,input().split())
grid = []

for i in range(H):
  line = list(input())
  grid.append(line)

mod_grid = []
for i in range(H):
  if '
    mod_grid.append(grid[i])
    
mod_grid = np.array(mod_grid).T
mod_grid2 = []
for i in range(W):
  if '
    mod_grid2.append(mod_grid[i])
    
mod_grid2 = np.array(mod_grid2).T
for i in range(mod_grid.shape[1]):
  if '
    print(''.join(mod_grid2[i]))

Solution (Python):
h, w = map(int, input().split())
a = [str(input()) for i 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):


def main():
    high, width = map(int, input().split())
    data = [list(input()) for i in range(high)]

    for i in range(high)[::-1]:
        if data[i].count('
            data.pop(i)

    for i in range(width)[::-1]:
        flg = 1
        for j in range(len(data)):
            if data[j][i] == '
                flg = 0
                break
        if flg:
            for j in range(len(data)):
                data[j].pop(i)

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

if __name__ == '__main__':
    main()

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

ccheck = 0
for i, l in enumerate(STAGE):
	ccheck |= int(l.replace("

for l in STAGE:
	if "
		continue
	for f, c in zip(format(ccheck, "b").zfill(W), l):
		if "1" == f:
			print(c, end="")
	print("")

Solution (Python):
N, M = map(int, input().split())
a = [input() for i in range(N)]
counter = 0
numlist = []
delMlist = []

for i in range(N):
    
    if a[i].count('
        delMlist.append(i)


for i in delMlist:
    a.pop(i-counter)
    
    counter += 1


N = N - len(delMlist)

newlist = []
for i in range(N):   
    for j in range(M):
        if a[i][j] == '.' :
            numlist.append([i,j])
    newlist.append([a[i]])
llist = []
for i in range(N):
    
    llist.append(list(a[i]))

counter1 = 0
fst = ''
delNlist = []

for i in range(M):
    for j in range(N):
        
        if llist[j][i] == '.':
            counter1 += 1
        if counter1 == N:
            delNlist.append(i)
    counter1 = 0



counter2 = 0
if delNlist != []:
    for h in delNlist:
        for i in range(N):
            a[i] = (a[i][:h-counter2] + a[i][h+1-counter2:])
        counter2 += 1
for i in a:
    print(i)

Solution (Python):
import sys

h, w = map(int, input().split())
a_list = []

for i in range(h):
    tmp = input()
    if '
        a_list.append(list(tmp))

del_list = []

for i in range(w):
    tmp = ''
    for j in a_list:
        tmp += j[i]
    if not '
        del_list.append(i)

for i in del_list[::-1]:
    for j in range(len(a_list)):
        a_list[j].pop(i)

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

Solution (Python):
H, W = map(int, input().split())
a = []
for i in range(H):
    a.append(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):
    s = input()
    if '
        a.append(s)

new_a =[]

for i in range(W):
    for j in range(len(a)):
        if a[j][i] == '
            s = ""
            for k in range(len(a)):
                s += a[k][i]
            new_a.append(s)
            break

for i in range(len(new_a[0])):
    s = ""
    for j in range(len(new_a)):
        s += new_a[j][i]
    print(s)

Solution (Python):
h, w = map(int, input().split())
arr = [input() for j in range(h)]
tarr = []
counter = 0
for i in range(h):
    if arr[i].count("
        counter += 1
        tarr.append(arr[i])
tans = [["" for i in range(counter)] for j in range(w)]
for i in range(counter):
    for j in range(w):
        tans[j][i] = tarr[i][j]
counter2 = 0
ttans = []
for i in range(w):
    if tans[i].count("
        counter2 += 1
        ttans.append(tans[i])
for i in range(counter):
    for j in range(counter2):
        print(ttans[j][i], end="")
        if j == counter2-1:
            print("")

Solution (Python):
h, w = map(int, input().split())
arr = [input() for j in range(h)]
tarr = []
counter = 0
for i in range(h):
    buf = arr[i]
    if buf.count("
        counter += 1
        tarr.append(buf)
tans = [["" for i in range(counter)] for j in range(w)]
for i in range(counter):
    for j in range(w):
        tans[j][i] = tarr[i][j]
counter2 = 0
ttans = []
for i in range(w):
    buf = tans[i]
    if buf.count("
        counter2 += 1
        ttans.append(buf)
for i in range(counter):
    for j in range(counter2):
        print(ttans[j][i], end="")
        if j == counter2-1:
            print("")

Solution (Python):


def solve(h, w, a):
    ret = []
    for r in a:
        left = False
        for c in r:
            if c == '
                left = True
                break
        if left:
            ret.append(r)
    ret2 = ['' for _ in range(len(ret))]
    for j in range(w):
        left = False
        for i in range(len(ret)):
            if ret[i][j] == '
                left = True
                break
        if left:
            for i in range(len(ret)):
                ret2[i] += ret[i][j]
    for r in ret2:
        print(r)
    return


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

if __name__ == '__main__':
    main()

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

num_col_white = [0] * W
for i in range(H):
  for j in range(W):
    if A[i][j] == '.':
      num_col_white[j] += 1

for i in range(H):
  if A[i].count('.') == W:
    continue
  row = ''
  for j in range(W):
    if num_col_white[j] != H:
      row += A[i][j]
  print(row)

Solution (Python):
h,w=map(int,input().split())
T=[list(input()) for i in range(h)]
while ["."]*w in T:
  T.remove(["."]*w)
  h-=1
T=list(list(i) for i in zip(*T))
while ["."]*h in T:
  T.remove(["."]*h)
T=list(list(i) for i in zip(*T))
for t in T:
  print("".join(t))

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


for r in rs:
  if '

ansrows = zip(*[c for c in zip(*rows) if '

for r in list(ansrows):
  print(''.join(r))

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

rows = [] 

for i in range(h):
  row = input()
  for c in row:
    if c == '
      rows.append(row)
      break
      
columns = []
column = ''
for i in range(w): 
  for j in range(len(rows)): 
    if rows[j][i:i+1] == '
      for k in range(len(rows)):
        column += rows[k][i:i+1]
      columns.append(column)
      column = ''
      break
      
r = len(columns[0]) 
ansrows = [''] * r
for i in range(r): 
  for j in range(len(columns)): 
  	ansrows[i] += columns[j][i]


for ans in ansrows: print(ans)

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


def compress(b, h, w):
  b = [c for c in b if '
  b = [''.join(x) for x in zip(*b)]
  b = [c for c in b if '
  b = [''.join(x) for x in zip(*b)]
  if len(b) == h and len(b[0]) == w:
    return b
  return compress(b, len(b), len(b[0]))

r = compress(a, H, W)
for i in range(len(r)):
  print(r[i])

Solution (Python):
h,w=map(int,input().split());print(*["".join(e)for e in zip(*["".join(e)for e in zip(*[e for e in[input()for _ in[0]*h]if"

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):
    ai=input()
    if ai=="."*W:
        continue
    a.append(ai)
h=len(a)
def tenti(a):
    b=[]
    h=len(a)
    w=len(a[0])
    for i in range(w):
        bi=[]
        for j in range(h):
            bi.append(a[j][i])
        b.append(bi)
    return b
b=tenti(a)
h=len(b)
w=len(b[0])
c=[]
for i in range(h):
    if b[i]==["."]*w:
        continue
    c.append(b[i])
d=tenti(c)
for i in range(len(d)):
    for j in range(len(d[0])):
        if j==len(d[0])-1:
            print(d[i][j])
            break
        print(d[i][j],end="")

Solution (Python):


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

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



a_new = list()

for i, li  in enumerate(a):
    if a[i].count('.')  != w:
        a_new.append(a[i])

b = [list(i) for i in zip(*a_new)]


b_new = list()

for i, li  in enumerate(b):
    if b[i].count('.')  != len(b[0]):
        b_new.append(b[i])

c = [list(i) for i in zip(*b_new)]
for i in c:
    print(''.join(i))

Solution (Python):
H,W = map(int,input().split())
A = []
B = []
for i in range(H):
    a = list(input())
    if a != ["."]*W:
        A.append(a)
for i in range(W):
    cnt = 0
    for j in range(len(A)):
        if A[j][i] != '.':
            cnt += 1
    if cnt == 0:
        B.insert(0,i)
for i in range(len(A)):
    for j in range(len(B)):
        del A[i][B[j]]
for i in range(len(A)):
    ans = "".join(A[i])
    print(ans)

Solution (Python):
H,W = map(int, input().split())
A = []
B = []
for i in range(H):
  a = list(input())
  if a != ["."]*W:
    A.append(a)
for i in range(W):
  cnt = 0
  for j in range(len(A)):
    if A[j][i] != ".":
      cnt += 1
  if cnt == 0:
    B.insert(0,i)
for i in range(len(A)):
  for j in range(len(B)):
    del A[i][B[j]]
for i in range(len(A)):
  ans = "".join(A[i])
  print(ans)

Solution (Python):
def generate_transposed_grid(grid):
    t_grid = [[None] * len(grid) for i in range(len(grid[0]))]
    for i in range(len(grid)):
        for j in range(len(grid[0])):
            t_grid[j][i] = grid[i][j]
    return t_grid


def generate_compressed_grid(grid):
    return [s for s in grid if not s == ['.'] * len(s)]


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

for _ in range(2):
    grid = generate_compressed_grid(grid)
    grid = generate_transposed_grid(grid)

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