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 = [[x for x in str(input())] for _ in range(H)]

x = 0
for h in range(H-1, -1, -1):
    if A[h].count('.') == W:
        del A[h]
        x += 1

for w in range(W-1, -1, -1):
    count = 0
    for h in range(H-x):
        if A[h][w] == '.':
            count += 1
    if count == H-x:
        for h in range(H-x-1, -1, -1):
            del A[h][w]

for h in range(H-x):
    print(''.join(A[h]))

Solution (Python):
import numpy as np

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

li = []
for i in range(h):
    a = list(input())
    li.append(a)

count = 0
li_2 = []
for i in range(h):
    for j in range(w):
        if li[i][j] == '
            li_2.append(list(li[i][:]))
            count += 1
            break
li_3 = []
li_2 = [list(x) for x in zip(*li_2)]

count2= 0
for j in range(w):
    for k in range(count):
        if li_2[j][k] == '
            li_3.append(li_2[j][:])
            count2 += 1
            break


li_3 = [list(y) for y in zip(*li_3)]

for i in range(count):
    for j in range(count2):
        print(li_3[i][j], end='')
        if j == count2-1:
            print('')

Solution (Python):

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

a_ = []

for i in range(h):
    ai = input()
    if ai!='.'*w:
        a_.append(ai)

h = len(a_)

a = [[a_[i][j] for j in range(w)] for i in range(h)]

rmv = set()
for j in range(w):
    flag = True
    for i in range(h):
        if a[i][j] =="
            flag = False
            break
    if flag:
        rmv.add(j)

for i in range(h):
    rem = []
    for j in range(w):
        if j not in rmv:
            rem.append(a[i][j])
    print("".join(rem))

Solution (Python):
h, w = map(int, input().split())
mat = []
mat_1 = []
mat_2 = []
mat_3 = []
mat_4 = []

for i in range(h):
    line = list(input())
    mat.append(line)



for i in range(h):
    line = mat[i]
    if line.count(".") != w:
        mat_1.append(line)




for line in zip(*mat_1):
    mat_2.append(list(line))



for i in range(len(mat_2)):
    line = mat_2[i]
    if line.count(".") != len(mat_2[0]):
        mat_3.append(line)




for line in zip(*mat_3):
    mat_4.append(list(line))


for line in mat_4:
    print(*line, sep="")

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

al_l = []

for _ in range(h):
    al = list(input())
    al_l.append(al)


for al in al_l:
    for idx, a in enumerate(al):
        tmp = [i[idx] for i in al_l]
        if "
            pass
        else:
            print(a, 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())
T = list(map(str, input()))
dic = {}
M = []
M.append(T)
for i in range(W):
    if T[i] == '.':
        dic[i] = 1
for i in range(H-1):
    T = list(map(str, input()))
    for j in range(W):
        if T[j] == '.' and j in dic:
            dic[j] += 1
    M.append(T)

for i in range(H):
    t = 0
    for j in range(W):
        if M[i][j] == '.':
            t += 1
        if j in dic and dic[j] == H:
            M[i][j] = ''
    if not t == W:
        print(''.join(M[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):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
  h, w = MAP()
  a = [list(input()) for _ in range(h)]
  g = []
  r = []
  for i in range(h):
    for j in range(w):
      if a[i][j] == "
        g.append(i)
        r.append(j)
  g = set(g)
  r = set(r)
  
  
  for i in g:
    for j in r:
      print(a[i][j], end='')
    print()

if  __name__=='__main__':
    main()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

H, W = MAP()
a = [list(input()) for _ in range(H)]



















gyou = set()
retu = set()

for i in range(H):
	for j in range(W):
		if a[i][j] == "
			retu.add(j)
			gyou.add(i)


for g in gyou:
	for r in retu:
		print(a[g][r], end="")
	print()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

H, W = MAP()
a = [list(input()) for _ in range(H)]

a = [s for s in a if s != ["."]*W]

b = [[0]*len(a) for _ in range(len(a[0]))]
for i in range(len(a)):
	for j in range(len(a[0])):
		b[j][i] = a[i][j]

b = [s for s in b if s != ["."]*len(b[0])]

c = [[0]*len(b) for _ in range(len(b[0]))]

for i in range(len(b)):
	for j in range(len(b[0])):
		c[j][i] = b[i][j]

for s in c:
	print("".join(s))

Solution (Python):

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

grid_after_operations = []

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

for j in reversed(range(w)):
    if grid_after_operations[0][j] == '.':
        for i in range(1, len(grid_after_operations)):
            if grid_after_operations[i][j] != '.':
                break
        else:
            for i in range(len(grid_after_operations)):
                grid_after_operations[i] = grid_after_operations[i][:j] + grid_after_operations[i][j + 1:]

for i in range(len(grid_after_operations)):
    print(grid_after_operations[i])

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

h,w= [int(x) for x in stdin.readline().rstrip().split()]

li = [["" for i in range(w)]for j in range(h)]

for i in range(h):
    s = stdin.readline().rstrip()
    for j in range(w):
        li[i][j] = s[j]

li = np.asarray([s for s in li if s != ['.']*w]).T.tolist()
li = np.asarray([s for s in li if s != ['.']*len(li[0])]).T.tolist()

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

Solution (Python):
hw = [int(i) for i in input().split()]
a = [list(input()) for _ in range(hw[0])]
for i in range(2):
  c = 0
  for ai in a:
    if all([aij == "." for aij in ai]):
      c += 1
  for j in range(c):
    a.remove(["."] * len(a[i]))
  a = [list(ai) for ai in zip(*a)]
for ai in a:
  print("".join(ai))

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

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

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

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

for i in reversed(range(h)):
  if all(j=="." for j in l[i]):
    l.pop(i)
for i in reversed(range(w)):
  if all(j[i]=="." for j in l):
    for j in l:
      j.pop(i)
for i in l:
  print(''.join(i))

Solution (Python):
h,w=map(int,input().split())
a=[]
for i in range(h):
    a.append(list(input()))
j=0
lis=[]
l=[]
count=0
for i in range(h):
    for j in range(w):
        if a[i][j]!='.':
            break
        if j==w-1:
            l.append(i)
x=0
while x<len(l):
    del a[l[x]-count]
    count+=1 
    x+=1

for k in range(len(a)):
    for l in range(w):
        if a[k][l]=='.':
            c=0
            while c<len(a):
                if a[c][l]!='.':
                    break
                if c==len(a)-1 and l not in set(lis):
                    lis.append(l)
                c+=1
ans=''

tmp=0
count=0
for o in range(len(lis)):
    tmp=lis[o]
    for s in range(len(a)):
        del a[s][tmp-count]
    count+=1    
for q in range(len(a)):
    for e in range(len(a[0])):
        ans+=a[q][e]
    print(ans)
    ans=''

Solution (Python):
h,w=map(int,input().split())
a=[input() for i in range(h)]
b=[]
for i in range(h):
    ans=True
    for j in range(w):
        if a[i][j]=='
            ans=False
    if ans:
        b.append(i)
for i in reversed(b):
    a.pop(i)
h-=len(b)
for j in range(w-1,-1,-1):
    ans=True
    for i in range(h-1,-1,-1):
        if a[i][j]=="
            ans=False
    if ans:
        for i in range(h-1,-1,-1):
            a[i]=a[i][:j]+a[i][j+1:]
for i in range(h):
    print(a[i])

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

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

mat2 = []
for row in mat:
    isAllWhite = True
    for x in row:
        if x == '
            isAllWhite = False
            break
    if not isAllWhite:
        mat2.append(row)

hh = len(mat2)
mat3 = [[] for i in range(hh)]
for i in range(w):
    isAllWhite = True
    for j in range(hh):
        if mat2[j][i] == '
            isAllWhite = False
            break
    if not isAllWhite:
        for j in range(hh):
            mat3[j].append(mat2[j][i])

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

Solution (Python):
h, w = map(int, input().split())
a = []
for i in range(h):
	a.append(input())
ind1 = []
for i in range(h):
	if "
		ind1.append(i)
ind2 = []
for i in range(w):
	judge = 0
	for j in range(h):
		if "
			judge = 1
	if judge:
		ind2.append(i)
for i in range(len(ind1)):
	s = []
	for j in range(len(ind2)):
		s.append(a[ind1[i]][ind2[j]])
	print("".join(map(str, s)))

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]
H,W=map(int,input().split())
a=[input() for i in range(H)]
l=[0]*W
for i in a:
    for j in range(W):
        if i[j]=="
            l[j]+=1
for i in a:
    if "
        for j in range(W):
            if l[j]:
                print(i[j],end="")
        print()

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

for _ in range(100):
    for i, row in enumerate(a):
        if "
            a.pop(i)
            break

    for i, col in enumerate(zip(*a)):
            if "
                for j, row in enumerate(a):
                    a[j].pop(i)
                break

for row in a:
    for sign in row:
        print(sign, end="")
    print()

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

aa = [row for row in a if "
aaa = [row for row in zip(*aa) if "
for _ in zip(*aaa):
    print(*_, sep="")

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

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

for i in range(h):
    if row[i]:
        s = ''
        for j in range(w):
            if col[j]:
                s += lis[i][j]
        print(s)

Solution (Python):
import numpy as np
h, w = map(int, input().split())
a = [[c for c in input()] for i in range(h)]
a = np.array(a)
colums = []
rows = []
for i in range(h):
    if not np.all(a[i] == '.'):
        colums.append(i)
for i in range(w):
    if not np.all(a[:, i] == '.'):
        rows.append(i)
a = a[colums]
for l in a[:, rows]:
    print(''.join(l))

Solution (Python):
from copy import deepcopy
H, W = map(int, input().split())
alist = [list(input()) for _ in range(H)]
acopy = deepcopy(alist)
counter = 0
for i in range(W):
    for a in alist:
        if a[i] == "
            break
    else:
        for a in acopy:
            a.pop(i - counter)
        counter += 1

for a in acopy:
    if "
        print("".join(a))

Solution (Python):




import sys














def main():
    h, w = (int(x) for x in sys.stdin.readline().split())
    a = [list(sys.stdin.readline().rstrip()) for _ in range(h)]
    
    for i in range(len(a)-1, -1, -1):
        for j in range(len(a[0])-1, -1, -1):
            if a[i][j] == '
                break
        else:
            del a[i]

    for j in range(len(a[0])-1, -1, -1):
        for i in range(len(a)-1, -1, -1):
            if a[i][j] == '
                break
        else:
            for i in range(len(a)-1, -1, -1):
                del a[i][j]

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

if __name__ == "__main__":
    
    main()

Solution (Python):
H, W = map(int, input().split())
S = [input() for _ in range(H)]
  
flag = True
cols = []
rows= []
  
for i in range(0, H):
  flag = True
  for j in range(0, W):
    if S[i][j] == '
      flag = False
  if flag:
    cols.append(i)

for i in range(0, W):
  flag = True
  for j in range(0, H):
    if S[j][i] == '
      flag = False
  if flag:
    rows.append(i)
      
for i in range(0, H):
  for j in range(0, W):
    if i not in cols and j not in rows:
      print(S[i][j], end="")
  if i not in cols:
    print()

Solution (Python):
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

import numpy as np

H,W=two_int()



output = []
for i in range(H):
    row = list(one_str())

    temp = list(set(row))
    if temp[0]=="." and len(temp)==1:
        continue
    
    output.append(row)

output = np.asarray(output).T



fin=[]
for row in output:
    temp = list(set(row))
    if temp[0]=="." and len(temp)==1:
        continue
    
    fin.append(row)
output = np.asarray(fin).T


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

Solution (Python):
h, w = map(int, input().split())
A = [ input() for _ in range(h) ]
whitew, whiteh = "." * w, "." * h
temph, tempw = 0, 0
for i in range(h):
  if A[i-temph] == whitew:
    A.pop(i-temph)
    temph += 1
    h -= 1
for i in range(w):
  b = True
  for j in range(h):
    if A[j][i-tempw] != ".":
      b = False
  if b:
    for j in range(h):
      A[j] = A[j][:i-tempw] + A[j][i-tempw+1:]
    tempw += 1
    w -= 1
for i in range(h):
  print(A[i])

Solution (Python):
h,w = map(int,input().split())
A = [list(map(str,input())) for i in range(h)]
for k in range(max(h,w)):
    counter = 0
    for i in range(h):
        if '
            del(A[i-counter:i-counter+1])
            counter += 1
            h -= 1
        if i-counter >= h-1:
            break
    counter = 0
    B = [list(row) for row in zip(*A)]
    for j in range(w):
        if '
            del(B[j-counter:j-counter+1])
            counter += 1
            w -= 1
        if j-counter >= w-1:
            break
    A = [list(row) for row in zip(*B)]
for row in A:
    print(*row, sep='')

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


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

ans=['']*H
for i in range(H):
    for j in range(W):
        if Tate[i]*Yoko[j]>0:
            ans[i]+=A[i][j]

for i in ans:
    if i!='':
        print(i)

Solution (Python):

import re
H, W = map(int, input().split())
l = []
for i in range(H):
  a = input()
  if(len(re.findall('
    l.append(a)


hh = len(l)
l2 = []
for j in range(W):
  if(l[0][j] == '.'):
    flag = 0
    for k in range(hh):
      if(l[k][j] == '
        flag = 1
    if(flag == 0):
      l2.append(j)


l3 = list(range(W))

l4 = list(set(l3) - set(l2))


for k in range(hh):
  a = ''
  for ll in l4:
   
   a = a + l[k][ll]
  print(a)

Solution (Python):
H, W = [int(x) for x in input().split()]
rows = [input() for _ in range(H)]
lst = []
tmp = []
for row in rows:
    if '
for i in range(W):
    column = ''
    for row in lst:
        column += row[i]
    if '
        tmp.append(i)
for row in lst:
    for i in range(W):
        if (i in tmp): continue
        print(row[i], end='')
    print()

Solution (Python):
h,w = map(int, input().split())
grid = [list(input()) for i in range(h)]
for i in reversed(range(h)):
    if all(j=="." for j in grid[i]):
        grid.pop(i)
for i in reversed(range(w)):
    if all(j[i]=="." for j in grid):
        for j in grid:
            j.pop(i)
for i in grid:
    print("".join(i))

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

A = []
for i in range(H):
  A_i = input()
  A.append(A_i)
  for j, a in enumerate(A_i):
    if a == "
      bl_H[i] = True
      bl_W[j] = True

for i, h in enumerate(bl_H):
  for j, w in enumerate(bl_W):
    if h and w:
      print(A[i][j], end="")
  if h:
    print()

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

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())
l=[]
l2=[]

for i in range(H):
    a=list(input())
    if a.count("
        l.append(a)

l1=list(zip(*l))
i=0
while i < len(l1):
    if l1[i].count("
        l2.append(l1[i])
    i+=1
l3=list(zip(*l2))
for i in range(len(l3)):
    print("".join(l3[i]))

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())
p=[1 for x in range(w)]
l=list()

for i in range(h):
  s=input()
  if '
    l.append(s)
    for j in range(w):
      p[j] *= 1 if s[j]=='.' else 0

for i in range(len(l)):
  for j in range(w):
    if p[j]==0:
      print(l[i][j],end='')
  print()

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

ans = []

for h in range(H):
    line = input()
    if "
        ans.append(line)


lines = zip(*ans)
ans = []

for line in lines:
    if "
        ans.append(line)

an = zip(*ans)

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

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

ans = []

for h in range(H):
    line = input()
    if "
        ans.append(line)

H = len(ans)
W = len(ans[0])


rem_list = []
for w in range(W):
    ver = [s[w] for s in ans]
    if "
        continue
    rem_list.append(w)

for h in range(H):
    new_ans = []
    for w in range(W):
        if w in rem_list:
            continue
        new_ans.append(ans[h][w])
    ans[h] = new_ans

for i in range(len(ans)):
    for j in range(len(ans[0])):
        print(ans[i][j], end="")
        if j >= len(ans[0])-1:
            print()

Solution (Python):
h,w=map(int,input().split())
s=[list(input())for i in range(h)]
l=[x for x in s if '
ans=[]
for i in zip(*l):
  if '
an=zip(*ans)
for x in an:
  print(''.join(x))

Solution (Python):
H,W = map(int,input().split())
a = [list(input()) for i in range(H)]
ver = []
hor = []
for j in range(W):
    tmp = []
    for i in range(H):
        tmp.append(a[i][j])
    if tmp == ["."]*H:
        ver.append(j)
for i in range(H):
    if a[i] == ["."]*W:
        hor.append(i)
ver = list(set(list(range(W)))-set(ver))
hor = list(set(list(range(H)))-set(hor))
ans = []
for i in hor:
    tmp = []
    for j in ver:
        tmp.append(a[i][j])
    ans.append(tmp)
for i in range(len(ans)):
    print("".join(ans[i]))

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

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

ans = list()

for line in a:
	if {'
		ans.append(line)

column_list = list()

for column in range(len(ans[0])):
	count = 0
	
	for line in ans:
		if line[column] == '.':
			count += 1
		else:
			count = 0
			break
	if count == len(ans):
		column_list.append(column)

column_list.sort(reverse=True)

for line_num in range(len(ans)):
	for pop_column in column_list:
		ans[line_num].pop(pop_column)

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

Solution (Python):
H, W = map(int, input().split())
g = []
cols = set()
for _ in range(H):
    r = input()
    if r != "." * W:
        g.append(r)
        for i in range(W):
            if r[i] == "
                cols.add(i)
cols = sorted(cols)
for r in g:
    print(*[r[i] for i in cols], sep="")

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

HW_list = []
for i in range(H):
    x = input()
    char_list = list(x)
    if "
        HW_list.append(char_list)
    else:
        pass

i = 0
while True:
    count = 0
    for j in range(len(HW_list)):
        if HW_list[j][i] == ".":
            count += 1
        
    if count == len(HW_list):
        for j in range(len(HW_list)):
            del HW_list[j][i]

    else:
        i += 1
    if i > len(HW_list[0]) - 1:
        break
    
for j in range(len(HW_list)):
    print("".join(HW_list[j]))

Solution (Python):
h, w = map(int, input().split())
g = []
for _ in range(h):
    r = input()
    if r != "."*w:
        g.append(r)

gg = ["" for _ in range(len(g))]

for i in range(w):
    if "".join([g[j][i] for j in range(len(g))]) != "." * len(g):
        for j in range(len(g)):
            gg[j] += g[j][i]
print(*gg, sep="\n")

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

for i in range(H-1, -1, -1):
    if "
        a.pop(i)

flag = False
for j in range(W-1, -1, -1):
    for i in range(len(a)):
        if a[i][j] == "
            flag = True
    if not flag:
        for i in range(len(a)):
            a[i] = a[i][:j] + a[i][j+1:]
    flag = False

for b in a:
    print(b)

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

b=[]
for x in a:
  if "
    b.append(x)

c=[]
for y in zip(*b):
  if "
    c.append(y)
c1=[]
c1=zip(*c)
    


for d in c1:
  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 = []
for i in range(h):
    wi = input()
    if wi != "."*w:
        a.append(wi)
b = zip(*[x for x in zip(*a) if "
for i in b:
    print("".join(i))

Solution (Python):
h, w = map(int, input().split())
a = []
for i in range(h):
    wi = input()
    if wi != "."*w:
        a.append(wi)
b = []
for j in range(w):
    wi2 = ""
    for i in range(len(a)):
        wi2 += a[i][w-j-1]
    if wi2 != "."*len(a):
        b.append(wi2)
ans = []
for i in range(len(b[0])):
    hi3 = ""
    for j in range(len(b)):
        hi3 += b[len(b)-j-1][i]
    print(hi3)

Solution (Python):
H, W = map(int, input().split())
gr = []
for i in range(H):
	w = input()
	if set(w) == {"."}:
		pass
	else:
		gr.append(w)

gr = [list(x) for x in zip(*gr)]
GR = []
for j in range(W):
	w = gr[j]
	if set(w) == {"."}:
		pass
	else:
		GR.append(w)
GR = [list(x) for x in zip(*GR)]
for i in range(len(GR)):
	print("".join(GR[i]))

Solution (Python):
import sys
input = sys.stdin.readline
H, W = map(int, input().split())
a = [list(input())[: -1] for _ in range(H)]
b = []
c = set()

for i in range(H):
  f = 1
  for j in range(W):
    if a[i][j] == ".":
      f = 0
    else:
      f = 1
      break
  if f: b.append(a[i])

for j in range(W):
  f = 0
  for i in range(len(b)):
    if b[i][j] == ".":
      f = 1
    else:
      f = 0
      break
  if f: c.add(j)

for i in range(len(b)):
  res = ""
  for j in range(W):
    if j in c:
      continue
    res += b[i][j]
  print(res)

Solution (Python):
def removeRow(s, i):
  return s[:i] + s[i+1:]

def removeCol(s, j):
  for i in range(len(s)):
    s[i] = s[i][:j] + s[i][j+1:]
  return s

def isWhiteRow(s, i):
  return s[i].count("

def isWhiteCol(s, j):
  res = True
  for i in range(len(s)):
    res &= s[i][j] == "."
  return res

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

while True:
  changed = False
  for i in range(len(a)):
    if isWhiteRow(a, i):
      a = removeRow(a, i)
      changed = True
      break
  for j in range(len(a[0])):
    if isWhiteCol(a, j):
      a = removeCol(a, j)
      changed = True
      break
  if not changed:
    for s in a:
      print(s)
    exit()

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

nrow = len(mat[0])
row_checked_mat = [row for row in mat if not row.count('.') == nrow]

ncol = len(row_checked_mat)
col_checked_mat = [col for col in zip(*row_checked_mat) if not col.count('.') == ncol]

for mat_i in zip(*col_checked_mat):
  print(*mat_i, sep='')

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


l=[]
for j in range(W):
  b = [x[j] for x in a]
  if '
    
    l.append(b)
    

for k2 in range(len(l[0])):
  for k in range(len(l)):
  	print(l[k][k2],end='')
  print("")

Solution (Python):
import numpy as np

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

mat = np.zeros((H, W))
original_mat = []

removed_line = []
removed_column = []

for i in range(H):
    row = input()
    line = []
    for j, c in enumerate(row):
        if c == "
            mat[i, j] = 1

    
    if np.sum(mat[i,:]) == 0:
        removed_line.append(i)
    else:
        original_mat.append(row)

for i in range(W):
    
    if np.sum(mat[:,i]) == 0:
        removed_column.append(i)




for row in original_mat:
    for i, c in enumerate(row):
        if i not in removed_column:
            print(c, end="")
    print("\n", end="")

Solution (Python):
import numpy as np

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

for _ in range(H):
    line = list(str(input()))
    if '
        continue
    else:
        ans.append(line)

ans = np.array(ans).T.tolist()
hoge = []
for i in range(len(ans)):
    line = ans[i]
    if '
        continue
    else:
        hoge.append(line)

ans = np.array(hoge).T.tolist()

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

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

Solution (Python):
def slove():
    import sys
    import bisect
    import collections
    import fractions
    import heapq
    input = sys.stdin.readline
    h, w = list(map(int, input().rstrip('\n').split()))
    a = [list(str(input().rstrip('\n'))) for _ in range(h)]
    hl = [True] * h
    wl = [True] * w
    for i in range(h):
        if a[i].count("
            hl[i] = False
    for i in range(w):
        b = False
        for j in range(h):
            if a[j][i] == "
                b = True
                break
        if not b:
            wl[i] = False
    for i in range(h):
        if hl[i]:
            l = []
            for j in range(w):
                if wl[j]:
                    l.append(a[i][j])
            print("".join(l))


if __name__ == '__main__':
    slove()

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

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

H = len(grid)

for i in reversed(range(W)):
    if all(grid[j][i] == "." for j in range(H)):
        for k in range(H):
            grid[k].pop(i)

print("\n".join("".join(r) for r in grid))

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

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



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

for i in range(H):
    ans = ""
    for j in range(W):
        if (i in row_list) and (j in col_list):
            ans += a[i][j]
    if(len(ans) > 0):
        print(ans)

Solution (Python):
if __name__ == "__main__":
    H, W = map(int, input().split())
    a = list()
    for i in range(H):
        a.append(input())
    
    
    col_list = list()
    row_list = list()

    for i in range(H):
        for j in range(W):
            if a[i][j] == '
                if (i in row_list) is False:
                    row_list.append(i)
                if (j in col_list) is False:
                    col_list.append(j)
    
    for i in range(H):
        ans = ''
        for j in range(W):
            if (j in col_list) and (i in row_list):
                ans += a[i][j]
        if len(ans) > 0:
            print(ans)