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):
MOD = 10 **9 + 7
INF = 10 ** 10
def main():
    H,W = map(int,input().split())
    grid = [list(input()) for _ in range(H)]
    for i in range(H - 1,-1,-1):
        flag = True
        for j in range(W):
            if grid[i][j] == '
                flag = False
                break
        if flag:
            grid = grid[:i] + grid[i + 1:]
            H -= 1

    for i in range(W - 1,-1,-1):
        flag = True
        for j in range(H):
            if grid[j][i] == '
                flag = False
                break
        if flag:
            for j in range(H):
                grid[j] = grid[j][:i] + grid[j][i + 1:]
    for i in range(H):
        print(''.join(grid[i]))
if __name__ == '__main__':
    main()

Solution (Python):
h, w = map(int, input().split())
a = []
for i in range(h):
    ai = [j for j in input()]
    if set(ai) == {'.'}:
        continue
    a.append(ai)
len_a = len(a)
at = list(zip(*a))
at2 = []
for ati in at:
    if set(ati) != {'.'}:
        at2.append(ati)
att = list(zip(*at2))
for ai in att:
    print(*ai, sep='')

Solution (Python):
h,w=map(int,input().split())
lis=[]
for i in range(h):
  lis.append(input())
tate=[]
yoko=[]
for i in range(0,w):
  for j in range(0,h):
    if lis[j][i]=="
      tate.append(i)
      break

for i in range(0,h):
  for j in range(0,w):
    if lis[i][j]=="
      yoko.append(i)
      break

for x in yoko:
  for y in tate:
    if y != tate[len(tate)-1]:
      print(lis[x][y],end="")
    else:
      print(lis[x][y])

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

b = []

for i in a:
    if i != '.' * W:
        b.append(i)

h = len(b)

ans = [[] for _ in range(h)]
        
for i in range(W):
    jdg = True
    for j in range(h):
        if b[j][i] != '.':jdg = False
        ans[j].append(b[j][i])
    if jdg:
        for j in range(h):
            ans[j].pop()

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

Solution (Python):
h,w=map(int,input().split())
A=[input() for i in range(h)]
B=[]
for i in range(h):
    if '
        B.append(A[i])
def rot(X):
    C=[]
    for l in range(len(X[0])):
        C_row=[]
        for m in X:
            C_row.append(m[l])
        C.append(C_row)
    return C
D=rot(B)
E=[]
for i in range(w):
    if '
        E.append(D[i])
F=rot(E)
for f in F:
    print(''.join(f))

Solution (Python):
h, w = map(int, input().split())
grid = []
ignore_i = []
ignore_j = []
for i in range(h):
    l = list(input())
    grid.append(l)
    
    if  not("
        ignore_i.append(i)

for j in range(w):
    white = True
    for i in range(h): 
        if grid[i][j] == "
            white = False
            break
    if white:
        ignore_j.append(j)




for i in range(h):
    if i in ignore_i:
        continue

    for j in range(w):
        if j in ignore_j:
            continue
        print(grid[i][j], end="")
    print("\n")

Solution (Python):
h,w=map(int,input().split())
a=[[1 if s=='
H=[]
W=[]
at=list(map(list,zip(*a)))
for i in range(h):
    if sum(a[i])==0:
        H.append(i)
for i in range(w):
    if sum(at[i])==0:
        W.append(i)
ans=[]
for i in range(h):
    if i not in H:
        ans.append([])
        for j in range(w):
            if j not in W:
                if a[i][j]==1:
                    ans[-1].append('
                else:
                    ans[-1].append('.')
for i in range(len(ans)):
    print(''.join(ans[i]))

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    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()



if __name__ == '__main__':
    main()

Solution (Python):


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

a2=[b for b in a1 if b.count('

a3=[b for b in list(zip(*a2)) if b.count('

ans=list(zip(*a3))

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

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

A = []

for i in range(H):
  S = input()
  if S != "."*W:
    A.append(S)

Wcount = [0]*W

for i in range(len(A)):
  for j in range(W):
    if A[i][j] == "
      Wcount[j] = 1

      
for i in range(len(A)):
  S = ""
  for j in range(W):
    
    if Wcount[j] == 1:
      S = S + str(A[i][j])
    
  print(S)

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

area = []
for i in range(h):
    tmp = str(input())
    if tmp.find('
        
        continue
    else:
        area.append(tmp)



area = list(zip(*area))



ans_list = []
for tmp in area:
    tmp = list(tmp)
    
    if ('
        
        continue
    else:
        ans_list.append(tmp)

ans_list = list(zip(*ans_list))



for tmp in ans_list:
    ans = ''    
    for j in tmp:
        ans += j
    print(ans)

Solution (Python):

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

row = [False for _ in range(h)]
col = [False for _ in range(w)]

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

Solution (Python):

import re
import math
from collections import defaultdict
import itertools
from copy import deepcopy
import random
from heapq import heappop,heappush
import time
import os
import queue
import sys
import datetime
from functools import lru_cache
readline=sys.stdin.readline
sys.setrecursionlimit(2000)

alphabet="abcdefghijklmnopqrstuvwxyz"
mod=int(10**9+7)
inf=int(10**20)
def yn(b):
    if b:
        print("yes")
    else:
        print("no")
def Yn(b):
    if b:
        print("Yes")
    else:
        print("No")
def YN(b):
    if b:
        print("YES")
    else:
        print("NO")
class union_find():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(N)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def is_power(a,b):
    now=b
    while now<a:
        now*=b
    if now==a:return True
    else:return False
def bin_(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def get_facs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def next_comb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:
        return num
def get_primes(n,type="int"):
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    if(type=="bool"):return A
    B=[]
    for a in range(n+1):
        if(A[a]):B.append(a)
    return B
def is_prime(num):
    if(num<=2):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(a,b,c):
    if a:return b
    else:return  c
def join(A,c=" "):
    n=len(A)
    A=list(map(str,A))
    s=""
    for a in range(n):
        s+=A[a]
        if(a<n-1):s+=c
    return s
def factorize(n,type_="dict"):
    b = 2
    list_ = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            list_.append(b)
        b+=1
    if n > 1:list_.append(n)
    if type_=="dict":
        dic={}
        for a in list_:
            if a in dic:
                dic[a]+=1
            else:
                dic[a]=1
        return dic
    elif type_=="list":
        return list_
    else:
        return None
def floor_(n,x=1):
    return x*(n//x)
def ceil_(n,x=1):
    return x*((n+x-1)//x)
def hani(x,min_,max_):
    ret=x
    if x<min_:ret=min_
    if x>max_:ret=max_
    return ret
def seifu(x):
    return x//abs(x)


def main():
    H,W=map(int,input().split())
    A=[input() for a in range(H)]
    dh=[]
    dw=[]
    for a in range(len(A)):
        if A[a]=="."*W:
            dh.append(a)
    for a in range(W):
        s=""
        for b in range(H):
            s+=A[b][a]
        if s=="."*H:
            dw.append(a)
    ans=[]
    for a in range(H):
        if a not in dh:
            ans.append("")
        else:
            continue
        for b in range(W):
            if b not in dw:
                ans[-1]+=A[a][b]
    for a in ans:
        print(a)

        
main()

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

board = list()
line = list()

for x in range(0, H):
    word = input()
    for y in word:
        line.append(y)
    if '
        board.append(line)
    line = list()

H = len(board)

goodx = [True]*W

judge = True

for a in range(0, W):
    for b in range(0, H):
        if board[b][a] == '
            judge = False
    if judge:
        goodx[a] = False
    judge = True

for a in range(0, H):
    for b in range(0, W):
        if goodx[b]:
            print(board[a][b], end='')
    print('')

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

num=[]
for i in range(w):
    for j in range(h):
        if A[j][i]=="
            num.append(i)
            break
for i in range(h):
    for j in num:
        print(A[i][j],end="")
    print()

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

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

for i in range(H):
    if i in row:
        continue
    ans = ''
    for j in range(W):
        ans += '' if j in clm else s[i][j]
    print(ans)

Solution (Python):
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def dijkstra_heap(s, edge, n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def lcm(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm, numbers, 1)


def gcd_list(numbers):
    return reduce(gcd, numbers)


def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True



def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P


def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret



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

x = []
y = []
for i in range(h):
    if a[i] == ["." for j in range(w)]:
        x.append(i)
for i in range(w):
    flag = True
    for j in range(h):
        if a[j][i] == "
            flag = False
            break
    if flag:
        y.append(i)


for i in range(h):
    flag = False
    for j in range(w):
        if i not in x and j not in y:
            flag = True
            print(a[i][j], end="")
    if flag:
        print()

Solution (Python):
import sys
from collections import deque, Counter, defaultdict
from itertools import accumulate  
from bisect import bisect_left, bisect
from heapq import heappop, heappush  
from fractions import gcd
from math import ceil, floor, sqrt
from copy import deepcopy

h, w = map(int, input().split())
rows = []
not_skip = defaultdict(bool)
for i in range(h):
    row = input()
    if "
        rows.append(row)
        for i in range(w):
            if row[i] == "
                not_skip[i] = True

for row in rows:
    for i in range(w):
        if not_skip[i]:
            print(row[i], end="")
    print()

Solution (Python):
def rotate(mat):
  mat2 = []
  for i in range(len(mat[0])):
    s = ""
    for k in range(len(mat)):
      s = s + mat[k][i]
    mat2.append(s)
  return mat2

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

for count in range(H+W):
  for i in range(len(mat)-1, -1, -1):
    if not "
      del mat[i]
  mat = rotate(mat)
  for i in range(len(mat)-1, -1, -1):
    if not "
      del mat[i]
  mat = rotate(mat)
  
for i in range(len(mat)):
  print(mat[i])

Solution (Python):
import numpy as np
H, W = map(int, input().split())
A = np.array([list(input()) for _ in range(H)])
del_i = []
for i in range(H):
    if all(A[i, :] == '.'):
        del_i.append(i)
del_j = []
for j in range(W):
    if all(A[:, j] == '.'):
        del_j.append(j)
A = np.delete(A, del_i, 0)
A = np.delete(A, del_j, 1)
for i in range(A.shape[0]):
    print(''.join(A[i]))

Solution (Python):
H,W = map(int,input().split())
S = []
for _ in range(H):
  a = list(input())
  if a.count('.') < W: S.append(a)
S_t = list(map(list, zip(*S)))
S_re = []
for i in range(W):
  if S_t[i].count('.') < len(S): S_re.append(S_t[i])

S_tt = list(map(list, zip(*S_re)))
for i in S_tt:
  print(''.join(i))

Solution (Python):



def main():
    H, W = [int(x) for x in input().split()]
    a = [input() for _ in range(H)]
    a = [ai for ai in a if "
    ar = zip(*[bi for bi in zip(*a) if "
    for ai in ar:
        print("".join(ai))


if __name__ == '__main__':
    main()

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

def main():
    H, W = map(int, readline().rstrip().split())
    mat = []
    for _ in range(H):
        inp = readline().rstrip()
        if '
            continue
        mat.append(list(inp))
    
    ws = []
    for w in range(W):
        flg = False
        for h in range(len(mat)):
            if mat[h][w] == '
                flg = True
                break
        if flg:
            ws.append(w)
    
    ans = [''.join([l[j] for j in range(len(l)) if j in ws]) for l in mat]
    print(*ans, sep='\n')


if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np


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

n = 0
for i in range(h):
    if all(a[n, :]=='.'):
        a = np.delete(a, n, axis=0)
    else:
        n += 1
n = 0
for i in range(w):
    if all(a[:, n]=='.'):
        a = np.delete(a, n, axis=1)
    else:
        n += 1

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=[list(input()) for a in range(h)]
a2=[b for b in a if b.count("
x=[b for b in list(zip(*a2)) if b.count("
y=list(zip(*x))
for a in y:
    print("".join(a))

Solution (Python):
h,w=map(int,input().split())
masulist=[list(input()) for a in range(h)]
masulist2=[b for b in masulist if b.count("
x=[b for b in list(zip(*masulist2)) if b.count("
y=list(zip(*x))
for a in y:
    print("".join(a))

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

h = []
for x in range(H):
    if all(a == '.' for a in grid[x]):
        h.append(x)
w = []
for y in range(W):
    if all(grid[x][y] == '.' for x in range(H)):
        w.append(y)


for x in range(H):
    if x in h:
        continue
    ans = []
    for y in range(W):
        if y not in w:
            ans.append(grid[x][y])
    print(*ans, sep='')

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

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

row = []
for i in range(w):
    for j in range(h):
        if vec[j][i] == '
            row.append(i)
            break

for i in line:
    for j in row:
        print(vec[i][j], end='')
    
    print()

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




num = []
for i in range(w):
    for j in range(h):
        if vec[j][i] == '
            num.append(i)
            break
    
for i in range(h):
    for j in num:
        print(vec[i][j], end='')
    
    print()

Solution (Python):
from functools import reduce
H, W =  map(int,input().split())
list1 = [input() for i in range(H)]
row_index = []
column_index =[]
[row_index.append(i) for i, elem in  enumerate(list1) if elem.count(".") < W]
[column_index.append(i) for i,elem in enumerate(zip(*list1)) if elem.count(".")<H]
for i in  row_index:
  for j in column_index:
    print(list1[i][j],end="")
  print("")

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

def rem(a):
    l = set([])
    c = set([])
    for i in range(len(a)):
        if ''.join(a[i]) == '.'*len(a[i]):
            l.add(i)
    for j in range(len(a[0])):
        col = ''.join([a[i][j] for i in range(len(a))])
        if col == '.'*len(a):
            c.add(j)
    if len(l) == 0 and len(c) == 0:
        return a
    else:
        a_new = []
        for i in range(len(a)):
            if i in l: continue
            line = []
            for j in range(len(a[0])):
                if j in c: continue
                line.append(a[i][j])
            a_new.append(line)
        return rem(a_new)
ans = rem(a)
for line in range(len(ans)):
    print(''.join(ans[line]))

Solution (Python):
H,W=map(int,input().split())
mas=[list(s for s in input()) for _ in range(H)]
height=[]
width=[]
for i in range(H):
    for j in range(W):
        if mas[i][j]=='
            height.append(i)
            width.append(j)

height=set(height)
height=list(height)
width=set(width)
width=list(width)
for a in height:
    ans=[]
    for b in width:
        ans.append(mas[a][b])
    print(*ans,sep='')

Solution (Python):
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

h,w = iim()
l = []
for i in range(h):
    s = list(input())
    if '
        l.append(s)

h = len(l)
for j in range(w)[::-1]:
    flag = True
    for k in range(h):
        if l[k][j] == '
            flag = False
    if flag:
        for n in range(h):
            l[n].pop(j)

for m in range(h):
    print(''.join(l[m]))

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

h_ans = h
del_list_h = []
for i in range(h):
    for j in range(w):
        if a_l[i][j] == '
            break
    else:
        del_list_h.append(i)
        h_ans -= 1

for i in del_list_h[::-1]:
    del a_l[i]

del_list_w = []
for j in range(w):
    for i in range(h_ans):
        if a_l[i][j] == '
            break
    else:
        del_list_w.append(j)

for j in del_list_w[::-1]:
    for k in range(h_ans):
        del a_l[k][j]

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

Solution (Python):
h,w=map(int,input().split())
S=[]
for i in range(h):
    s=input()
    if all([k=="." for k in s]):
        continue
    S.append(s)
if len(S)!=0:
    C=[]
    for j in range(w):
        if all([S[i][j]=="." for i in range(len(S))]):
            C.append(j)

for i in range(len(S)):
    for j in range(w):
        if j in C:
            continue
        print(S[i][j],end="")
    print("",end="\n")

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

for i in range(h):
    tmp = input()
    if(tmp != w*"."):
        A.append(tmp)

D = []

for j in range(w):
    flag = True
    for B in A:
        if(B[j] == "
            flag = False
    if(flag):
        D.append(j)

for B in A:
    for j in range(w):
        if(j not in D):
            print(B[j], end="")
    print()

Solution (Python):
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):
    return map(type,input().split())


def resolve():
    H,W=pin()
    maze=[list(input()) for oo in range(H)]
    vacanth=[]
    vacantw=[]
    for h in range(H):
        if "
    for w in range(W):
        flag=1
        for h2 in range(H):
            if maze[h2][w]=="
                flag=0
                break
        if flag==1:vacantw.append(w)

    for i in range(H):
        if i in vacanth:continue
        temp=""
        for j in range(W):
            if j in vacantw:continue
            temp+=maze[i][j]
        print(temp)
    

resolve()

Solution (Python):
import sys

from itertools import accumulate

def readlines(h, w):
    for _ in range(h):
        row = input()
        if not all(cell == "." for cell in row):
            yield row

def main():
    h, w = map(int, input().split())
    grid = list(readlines(h, w))

    columns = set()
    for i in range(w):
        if all(row[i]=="." for row in grid):
            columns.add(i)
    
    for i in range(len(grid)):
        for j in range(w):
            if j not in columns:
                print(grid[i][j], end="")
        print()


main()

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

a = list(zip(*[i for i in a if '
a = list(zip(*[i for i in a if '

for n in range(len(a)):
    print("".join(a[n]))

Solution (Python):
a,b = list(map(int,input().split()))
A = []
AAA = 0
list = [["" for i in range(b)] for j in range(a)]
for i in range(a):
    n = input()
    if n.count(".") == b:
       pass 
    else:
        for j in range(b):
            list[i][j] = n[j]
for i in range(b):
    for j in range(a):
        A.append(list[j][i])
    if len(A) == A.count(".")+A.count(""):
        for k in range(a):
            list[k][i] = ""
    A = []
for i in range(a):
    for j in range(b):
        if list[i][j] != "":
            print(list[i][j],end="")
            AAA = 1
    if AAA == 1:
        print()
    AAA = 0

Solution (Python):









import numpy as np







H,W = map(int,input().split())
board = []
for i in range(H):
    word = input()
    if "
        board.append(list(word))

board = np.array(board).T
ans = []
for b in board:
    if "
        ans.append(b)

ans = np.array(ans).T

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

Solution (Python):
def myAnswer(H:int,W:int,A:list) -> None:
   ans = []
   for a in A:
      for i in a:
         if(i == "
            ans.append(a)
            break
         
   ansT = list(zip(*ans))
   ans = []
   for t in ansT:
      for i in t:
         if(i == "
            ans.append(t)
            break
   ans = list(zip(*ans))
   for a in ans:
      string = ""
      for i in a:
         string +=i
      print(string)


def modelAnswer():
   return
def main():
   H,W = map(int,input().split())
   A = []
   for _ in range(H):
      A.append(list(input()))
   myAnswer(H,W,A[:])
if __name__ == '__main__':
   main()

Solution (Python):
def resolve():
    '''
    code here
    '''
    import numpy as np
    H, W = [int(item) for item in input().split()]
    grid = [[item for item in input()] for _ in range(H)]

    temp_grid = []
    for line in grid:
        temp = [item == '
        if any(temp):
            temp_grid.append(line)
            
    temp_grid = np.array(temp_grid)
    temp_grid2 = []
    for j in range(W):
        line = temp_grid[:,j]
        temp = [item == '
        if any(temp):
            temp_grid2.append(line)

    
    temp_grid2 = np.array(temp_grid2)
    res = np.rot90(temp_grid2, 3)
    
    for line in res:
        print(''.join(line[::-1]))




if __name__ == "__main__":
    resolve()

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 = []
colrow = []

for i in range(h):
    b = list(input())
    if set(b) == {"."}:
            continue
    a.append(b)

for x in zip(*a): 
    if set(x) == {"."}:
        continue
    colrow.append(x)

for x in zip(*colrow):
    print(*x, sep="")

Solution (Python):
h, w = map(int, input().split())
a = []
delcol = []
cnt = 0

for i in range(h):
    b = list(input())
    if set(b) == {"."}:
            continue
    a.append(b)

for i in range(w):
    for j in range(len(a)):
        if a[j][i] != ".":
            break
        else:
            cnt += 1
        if cnt == len(a):
            delcol.append(i)
    cnt = 0

for i in delcol [::-1]: 
    for j in range(len(a)):
        del a[j][i]

for i in range(len(a)):
    print(*a[i], sep="")

Solution (Python):
h, w = map(int, input().split())
a = []
delrow = []
delcol = []
cnt = 0

for i in range(h):
    a.append(list(input()))

for i in range(h):
    if set(a[i]) == {"."}:
        delrow.append(i)

for i in range(w):
    for j in range(h):
        if a[j][i] != ".":
            break
        else:
            cnt += 1
        if cnt == h:
            delcol.append(i)
    cnt = 0
        
for i in delrow [::-1]: 
    del a[i]
for i in delcol [::-1]: 
    for j in range(len(a)):
        del a[j][i]

for i in range(len(a)):
    print(*a[i], sep="")

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

grid = []
del_i = []
del_n = []

for i in range(num[0]):
  grid.append(list(input()))

  if "
    continue
  elif "
    continue
  else:
    del_i.append(i)

check_1, check_2 = 0, 0

for n in range(num[1]):
  check_1, check_2 = 0, 0
  for i in range(num[0]):
    if grid[i][n] == "
      check_1 += 1
      if check_2 > 0:
        break
      
      
    else:
      check_2 += 1
      if check_1 > 0:
        break
      if check_2 == num[0]:
        del_n.append(n)

for i in range(num[0]):
  if i in del_i:
    continue
  else:
    m = 0
    for n in del_n:
      n = n - m
      del grid[i][n]
      m += 1
    print(''.join(grid[i]))

Solution (Python):
h, w = map(int, input().split())
a = []
delrow = []
delcol = []
cnt = 0

for i in range(h):
    a.append(list(input()))

for i in range(h):
    for j in range(w):
        if a[i][j] != ".":
            break
        else:
            cnt += 1
        if cnt == w:
            delrow.append(i)
    cnt = 0

for i in range(w):
    for j in range(h):
        if a[j][i] != ".":
            break
        else:
            cnt += 1
        if cnt == h:
            delcol.append(i)
    cnt = 0

for i in delrow [::-1]: 
    del a[i]
for i in delcol [::-1]: 
    for j in range(len(a)):
        del a[j][i]

for i in range(len(a)):
    print(*a[i], sep="")

Solution (Python):
h, w = map(int, input().split())
grid = []
for i in range(h):
    temp = list(input())
    if set(temp) != {'.'}:
        grid.append(temp)


transpose = [list(x) for x in zip(*grid)]

ans = []
for l in transpose:
    if set(l) != {'.'}:
        ans.append(l)

ans = [list(x) for x in zip(*ans)]
for l in ans:
    print(''.join(l))