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






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]


def Yes(): print("Yes"); return
def No(): print("No"); return


def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


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 make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def Base_10_to_n(X, n):
  if (int(X/n)):
    return Base_10_to_n(int(X/n), n)+[X%n]
  return [X%n]






H,W = inputIL()
data = []
for _ in range(H):
  s = inputS()
  if s != "."*W:
    data.append(s)

memo = []
for i in range(W):
  flag = 1
  for j in range(len(data)):
    if data[j][i] == "
      flag = 0
  if flag == 0:
    memo.append(i)
    
ans = [[data[j][i] for i in memo] for j in range(len(data))]

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

Solution (Python):
H, W = map(int, input().split())
a = [input() for _ in range(H)]
grid = [[True]*W for _ in range(H)]
for i in range(H):
    flag = True
    for j in range(W):
        if a[i][j] == '
            flag = False
    if flag:
        for k in range(W):
            grid[i][k] = False

for i in range(W):
    flag = True
    for j in range(H):
        if a[j][i] == '
            flag = False
    if flag:
        for k in range(H):
            grid[k][i] = False  

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

lall = list()
for i in range(h):
    l = list(input())
    if l != ["."] * w:
        lall.append(l)

for i in range(w):
    j = 0
    while j < len(lall) and i < len(lall[j]) and lall[j][i] == ".":
        j += 1
        if j == len(lall):
            for k in range(len(lall)):
                lall[k][i] = "0"
            break    

for i in range(len(lall)):
    print(''.join([j for j in lall[i] if j != "0"]))

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

del_H = []
del_W = []
for i in range(H):
  for j in range(W):
    if a[i][j] == '
      break
    if j == W - 1:
      del_H.append(i)
for j in range(W):
  for i in range(H):
    if a[i][j] == '
      break
    if i == H - 1:
      del_W.append(j)
for i in range(H):
  if i not in del_H:
    for j in range(W):
      if j not in del_W:
        print(a[i][j], end="")
    print()

Solution (Python):
h, w = map(int, input().split())
a =[]
for i in range(h):
    row = list(input())
    if '
        a.append(row)
    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())
a_list = [input() for nesya in range(h)]

gyo = [False]*h
retsu = [False]*w
for i in range(h):
  for j in range(w):
    if a_list[i][j] == '
      gyo[i] = True
      retsu[j] = True
for k in range(h):
  if gyo[k]:
    for l in range(w):
      if retsu[l]:
        print(a_list[k][l], end='')
    print()

Solution (Python):
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
memo_yoko = []
memo_tate = []
for i in range(h):
    if "
        memo_yoko.append(i)

for j in range(w):
    if any(a[i][j] == "
        memo_tate.append(j)


for i in memo_yoko:
    for j in memo_tate:
        print(a[i][j], end="")
    print()

Solution (Python):
h,w = map(int,input().split())
a = [list(input()) for i in range(h)]
ha = 0
for i in reversed(range(h)):
    if set(a[i])=={"."}:
        a.pop(i)
        ha+=1
for i in reversed(range(w)):
    if set([s[i] for s in a])=={"."}:
        for j in range(h-ha):
            a[j].pop(i)
for ai in a:
    print("".join(ai))

Solution (Python):
h,w=map(int,input().split())
a=[list(input()) for _ in range(h)]
row=[]
col=[]
for i in range(h):
    if "
        row.append(i)
b=[list(x) for x in zip(*a)]
for j in range(w):
    if "
        col.append(j)
for i in row:
    for j in col:
        print(a[i][j],end="")
    print("")

Solution (Python):
import numpy as np

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

b = []
for i in a:
    if set(i) != {'.'}:
        b.append(i)
b = np.array(b)
b = b.T

c = []
for i in b:
    if set(i) != {'.'}:
        c.append(i)
c = np.array(c)
c = c.T

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

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


'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

h,w=map(int, input().split())
m = [list(input().rstrip()) for i in range(h)]
ok_w=[True for i in range(h)]
ok_h=[True for i in range(w)]

for i in range(h):
    for j in range(w):
        
        if "
           ok_w[i]=False
           ok_h[j]=False

for i in range(h):
    for j in range(w):
        if not ok_w[i] and not ok_h[j]:
            print(m[i][j],end="")
    print("\n",end="")

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

hlist, wlist = [], []
for i in range(h):
    if '
        hlist.append(i)
for j in range(w):
    if any(a[i][j] == '
        wlist.append(j)

for i in hlist:
    print(*[a[i][j] for j in wlist] ,sep='')

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18


h, w = Is()
A = LSR(h)
H = list(all(x == '.' for x in A[i]) for i in range(h))
W = list(all(x[j] == '.' for x in A) for j in range(w))
for i in range(h):
    if H[i]:
        continue
    for j in range(w):
        if W[j]:
            continue
        print(A[i][j], end='')
    print()

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

A = []
for i in range(h):
    a = list(input())
    if '
        A.append(a)
        
for i in range(w - 1, -1, -1):
    for j in range(len(A)):
        if A[j][i] == '
            break
    else:
        for k in range(len(A)):
            del A[k][i]
            
for a in A:
    print(''.join(a))

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

a = []


for i in range(H):
    tmp = list(input())
    if "
        continue
    else:
        a.append(tmp)


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

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

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

for h in range(H):
    a=list(input())
    A.append(a)

A=np.array(A)
hs=[]
ws=[]

for i in range(H):
    if (A[i,:]=="
        hs.append(i)
for i in range(W):
    if (A[:,i]=="
        ws.append(i)

for h in range(H):
    if h not in hs:
        L=[]
        for w in range(W):
            if w not in ws:
                L.append(A[h,w])
        print("".join(L))

Solution (Python):




h, w = map(int, input().split())
a_list = []
for i in range(h):
    _tmp = input()
    if set(_tmp).issuperset({"
        a_list.append(_tmp)

a_list_T = [list(x) for x in zip(*a_list)]
tmp_list = []

for i in range(w):
    _tmp = a_list_T[i]
    if set(_tmp).issuperset({"
        tmp_list.append(_tmp)
        
ans = [list(x) for x in zip(*tmp_list)]

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

Solution (Python):
H, W = list(map(int, input().split()))
A = [list(input()) for _ in range(H)]
delh, delw = [], []
for i in range(H):
    if all([True if i == '.' else False for i in A[i]]):
        delh.append(i)
B = [list(x) for x in zip(*A)]
for i in range(W):
    if all([True if i == '.' else False for i in B[i]]):
        delw.append(i)
B = [b for i, b in enumerate(B) if i not in delw]
A = [list(x) for x in zip(*B)]
A = [a for i, a in enumerate(A) if i not in delh]
[print(''.join(a)) for a in A]

Solution (Python):
import numpy as np

h, w = map(int,input().split())
grid = np.array([list(input()) for _ in range(h)], dtype="U1") 

row = []
col = []

for i in range(h):
    if (grid[i] != ".").any():
        row.append(i)

trans_grid = np.transpose(grid)

for i in range(w):
    if (trans_grid[i] != ".").any():
        col.append(i)

G = grid[row][:,col] 

for g in G:
    print("".join(g))

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


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    H, W = readnums()
    a = [list(readstr()) for _ in range(H)]
    p = list()
    for i, aa in enumerate(a):
        if all([x == '.' for x in aa]):
            p.append(i)

    for i in reversed(p):
        a.pop(i)

    p = list()
    for i in range(W):
        c = [x[i] for x in a]
        if all([x == '.' for x in c]):
            p.append(i)

    for i in reversed(p):
        for aa in a:
            aa.pop(i)

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


if __name__ == "__main__":
    main()

Solution (Python):
h, w = map(int, input().split())
a = [input() for _ in range(h)]
L = [1] * w
for i in range(w):
    if a[0][i] == '.':
        for j in range(h):
            if a[j][i] == '
                break
        else:
            L[i] = 0
for k in range(h):
    if '
        L2 = []
        for l in range(w):
            if L[l] == 1:
                L2.append(a[k][l])
        print(*L2, sep='')

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

    cond_r = [True] * H
    cond_c = [True] * W
    for r in range(H):
        if all(x == '.' for x in G[r]):
            cond_r[r] = False
    for c in range(W):
        if all(x == '.' for r in range(H) for x in G[r][c]):
            cond_c[c] = False
    for r, row in enumerate(G):
        if not cond_r[r]: continue
        for c, cell in enumerate(row):
            if not cond_c[c]: continue
            print(cell, end='')
        print()


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    h, w = map(int, input().split())
    ary = [list(input()) for _ in range(h)]
    for i in reversed(range(h)):
        if len(ary[i]) == ary[i].count('.'):
            del ary[i]
    for i in reversed(range(w)):
        ok = True
        for a in ary:
            if a[i] != '.':
                ok = False
        if ok:
            for j in range(len(ary)):
                del ary[j][i]
    for a in ary:
        print("".join(a))


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(map(int, input().replace("

a = np.array(a)

d1 = (np.sum(a, axis=1) == 0)
d2 = (np.sum(a, axis=0) == 0)

ret = []

for i in range(H):
    tmp = ""
    if d1[i]:
        continue
    for j in range(W):
        if d2[j]:
            continue
        tmp = tmp + str(a[i,j])
    ret.append(tmp.replace("1","
        

print(*ret,sep="\n")

Solution (Python):
H, W = map(int, input().split())
a = [list(input()) for i in range(H)]
A = [[0]*W for i in range(H)]
B = []
for i in range(H):
    for j in range(W):
        if a[i][j] == '
            A[i][j] += 1
    if sum(A[i]) > 0:
        B.append(A[i])

ans = [[] for i in range(len(B))]
for y in zip(*B):
    if sum(y) > 0:
        for i, x in enumerate(y):
            if x:
                ans[i].append('
            else:
                ans[i].append('.')
for x in ans:
    print(''.join(x))

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

resh=[]
h=len(a)
for i in range(w):
    for j in range(len(a)):
      if a[j][i]=="
        break
    else:
      resh.append(i)
for i in range(h):
  for j in range(w):
    if i not in res and j not in resh:
      print(a[i][j],end="")
  if i not in res:
    print("")

Solution (Python):


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

for i in range(h):
    l = list(input())
    if list(set(l)) == ['.']:
        h -= 1
    else:
        A.append(l)

    
Ans = []
for i in range(w):
    cnt = 0
    for j in range(h):
        if A[j][i] == '.':
            cnt += 1
    if cnt == h:
        Ans.append(i)

for i in Ans:
    for j in range(h):
        A[j][i] = ''

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

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

l = []
for i, v in enumerate(a):
    if "
        l.append(i)
for i in l[::-1]:
    a.pop(i)

a = list(zip(*a))
l = []
for i, v in enumerate(a):
    if "
        l.append(i)
for i in l[::-1]:
    a.pop(i)

a = list(zip(*a))
for i in a:
    print("".join(i))

Solution (Python):
import numpy as np
 
H,W = map(int,input().split())
MAP = []
for _ in range(H):
    tmp = tuple(input())
    MAP.append(tmp)
 
MAP = np.array(MAP)
L = []
for i in range(H):
    if all(MAP[i,:] == '.'):
        L.append(i)
 
MAP = np.delete(MAP,L,0)
L = []
for i in range(W):
    if all(MAP[:,i] == '.'):
        L.append(i)
 
MAP = np.delete(MAP,L,1)
for m in MAP:
    print(''.join(m))

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

A = [str(input()) for _ in range(H)]

LH = set([])
LW = set([])

for i in range(H):
  for j in range(W):
    if A[i][j] == "
      LH.add(i)
      LW.add(j)

UH = len(LH)
ans = []
for i in LH:
  temp = ""
  for j in LW:
    
    temp += A[i][j]
  ans.append(temp)
print(*ans, sep="\n")

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

for h in range(H):
    cnt = sum([0 if i=='.' else 1 for i in grid[h]])
    if cnt==0:
        grid[h] = [0]*W

for w in range(W):
    cnt = sum([0 if grid[h][w] in ('.', 0) else 1 for h in range(H)])
    if cnt == 0:
        for h in range(H):
            grid[h][w] = 0

for g in grid:
    string = [s for s in g if not s==0]
    if len(string)==0:
        continue
    print(''.join(string))

Solution (Python):
import sys
from collections import Counter
from collections import deque
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

h,w=mp()
l=[]
for i in range(h):
    a=list(input())
    if a[0]!="." or len(list(set(a)))!=1:
        l.append(a)

i=0
while i<len(l[0]):
    ch=True
    for k in range(len(l)):

        if l[k][i]=="
            ch=False
    if ch:
        for k in range(len(l)):
            del l[k][i]
        i-=1
    i+=1
for i in range(len(l)):
    print(*l[i],sep="")

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

yoko = [1 for i in range(h)]
tate = [1 for i in range(w)]

for i in range(h):
    if a[i].count(".") == w:
        yoko[i] = 0

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

for i in range(w):
    if a_t[i].count(".") == h:
        tate[i] = 0

for i in range(h):
    s = ""
    for j in range(w):
        if yoko[i] and tate[j]:
            s += a[i][j]
    if s:
        print(s)

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

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

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

  
  if f:
    rm.append(i)

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


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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

    res = []
    for h in range(H):
        for w in range(W):
            if A[h][w] == "
                res.append(A[h])
                break

    res2 = [[] for _ in range(len(res))]
    for w in range(W):
        for h in range(len(res)):
            if res[h][w] == "
                for k in range(len(res)):
                    res2[k].append(res[k][w])
                break

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


if __name__ == '__main__':
    resolve()

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

yoko = []
tate = []

for i in range(H):
  if a[i] != "."*W:
    yoko.append(i)
for i in range(W):
  c = 0
  for j in range(H):
    if a[j][i] == "
      c = 1
  if c == 1:
    tate.append(i)

for y in yoko:
  s = ""
  for t in tate:
    s += a[y][t]
  print(s)

Solution (Python):
h,w = map(int, input().split())
a = [list(input()) for _ in range(h)]
A = list(zip(*a))
skip_h = [] 
skip_w = []
for i in range(h):
  if a[i] == ["."] * w: skip_h.append(i)
for i in range(w):
  if A[i] == tuple(".") * h: skip_w.append(i)

for i in range(h):
  if i in skip_h: continue
  ans = ""
  for j in range(w):
    if j in skip_w: continue
    ans += a[i][j]
  print(ans)

Solution (Python):
h, w = map(int, input().split())
a = []
for _ in range(h):
    a.append(input())
row = []
col = []
for i in range(h):
    for j in range(w):
        if a[i][j]=='
            break
    else:
        row.append(i)
for i in range(w):
    for j in range(h):
        if a[j][i]=='
            break
    else:
        col.append(i)
a = [[e for j, e in enumerate(r) if j not in col] for i, r in enumerate(a) if i not in row]    
for r in a:
    print(''.join(r))

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

row = []
col = []
for i in range(H):
    if (grid[i] != ".").any():
        row.append(i)

trans_grid = np.transpose(grid)
for i in range(W):
    if (trans_grid[i] != ".").any():
        col.append(i)


G = grid[row][:, col]
for g in G:
    print("".join(g))

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

hl = []
wl = []
for h in range(H):
    if sum([0 if i == "." else 1 for i in A[h]]) > 0:
        hl.append(h)

for w in range(W):
    if sum([0 if A[i][w] == "." else 1 for i in range(H)]) > 0:
        wl.append(w)

for h in hl:
    line = []
    for w in wl:
        line.append(A[h][w])
    print(*line, sep="")

Solution (Python):
def main():
    H, W = (int(i) for i in input().split())
    A = [input() for i in range(H)]
    ban_h = set()
    for h in range(H):
        if all(s == "." for s in A[h]):
            ban_h.add(h)
    ban_w = set()
    for w in range(W):
        if all("." == A[i][w] for i in range(H)):
            ban_w.add(w)

    for h in range(H):
        if h in ban_h:
            continue
        for w in range(W):
            if w in ban_w:
                continue
            print(A[h][w], end="")
        print()


if __name__ == '__main__':
    main()

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

kari = []
for i in a:
    if "
        H -= 1
        continue
    kari.append(i)

ans = ["" for _ in range(H)]
for i in range(W):
    for j in range(H):
        if kari[j][i] == "
            for k in range(H):
                ans[k] += kari[k][i]
            break

for i in ans:
    print(i)

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


H_flag = [False]*H
W_flag = [False]*W


_map = []
for i in range(H):
    x = list(input())
    _map.append(x)
    for j in range(W):
        if x[j] == '
            H_flag[i] = True

for i in range(W):
    for j in range(H):
        if _map[j][i] == '
            W_flag[i]= True

for i in range(H):
    for j in range(W):
        if H_flag[i] and W_flag[j]:
            print(_map[i][j],end="")
    if H_flag[i] :
        print()

Solution (Python):





def main():
    H, W = map(int, input().split())
    a = [None] * H
    for i in range(H):
        a[i] = input()

    b = []
    for i in range(H):
        if any([x == "
            b.append(a[i])
    
    idx = []
    for j in range(W):
        if any([b[i][j] == "
            idx.append(j)

    for i in range(len(b)):
        for j in range(W):
            if j in idx:
                print(b[i][j], end="")
        print()


main()

Solution (Python):
H,W = [int(hoge) for hoge in input().split()]
A = [input() for j in range(H)]
Row = [r for r in range(H) if all([m=="." for m in A[r]]) ]
Col = [c for c in range(W) if all([A[r][c]=="." for r in range(H)])]
print(*["".join([A[h][w]for w in range(W) if w not in Col]) for h in range(H) if h not in Row],sep="\n")

Solution (Python):
h, w = map(int, input().split())
ma = [list(str(input())) for _ in range(h)]
row = [0] * h
column = [0] * w 

for i in range(h):
    if ma[i] == ['.'] * w:
      row[i] = 1

j = 0
while j < w:
    count = 0
    for i in range(h):
        if ma[i][j] == '.':
            count += 1
        if count == h:
            column[j] = 1
    j += 1

for i in range(h):
    if row[i] == 1:
        for j in range(w):
            ma[i][j] = ''

for j in range(w):
    if column[j] == 1:
        for i in range(h):
            ma[i][j] = ''

for i in range(h):
    if ma[i].count('') == len(ma[i]): 
        continue
    else:
        print(''.join(ma[i]))

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

row=[0]*h
col=[0]*w

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

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

        print()

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

B = [""]*len(A)

for i in range(len(A[0])):
    b = False
    for j in range(len(A)):
        
        if A[j][i] == "
            b = True

    if b == True:
        for j in range(len(A)):
            B[j] += A[j][i]
        
    

for k in B:
    print(k)

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

for i in range(w):
	tmp=0
	for j in range(h):
		if a[j][i]=="
			tmp=1
	if tmp==0:
		for j in range(h):
			a[j][i]="0"


for i in range(h):
	if not "
		a[i][:]=[0]*w

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

Solution (Python):
inf = 10 ** 15
mod = 10 ** 9 + 7
h,w = map(int, input().split())
maps = [input() for i in range(h)]
remh = []
remw = []
for i in range(h):
    flag = True
    for j in range(w):
        if maps[i][j] == '
            flag = False
            break
    if not flag:
        remh.append(i)
for j in range(w):
    flag = True
    for i in range(h):
        if maps[i][j] == '
            flag = False
    if not flag:
        remw.append(j)

for num in remh:
    a = []
    for tmp in remw:
        a.append(maps[num][tmp])
    s = ''.join(a)
    print(s)

Solution (Python):
h,w=map(int,input().split())
alist=[]
numans=list(range(h))
for i in range(h):
    a=list(input())
    alist.append(a)
for i in range(h):
    if alist[h-i-1].count(".")==w:
        numans.remove(h-i-1)
lena=len(alist)
yn=0
for i in range(w):
    for j in range(lena):
        if alist[j][w-i-1]!=".":
            yn=1
    if yn==0:
        for j in range(lena):
            del alist[j][w-i-1]
    yn=0
c=""
lena=len(alist[0])
for i in numans:
    for j in range(lena):
        c+=alist[i][j]
    print(c)
    c=""

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

rows = [input() for _ in range(H)]
rows = [row for row in rows if '
cols = list(zip(*rows))
cols = [col for col in cols if '
rows = list(zip(*cols))

for row in rows:
    print(''.join(row))

Solution (Python):

import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W = lr()
A = [sr() for _ in range(H)]
B = []
for a in A:
    if '
        B.append(a)

B = zip(*[b for b in zip(*B) if '
for b in B:
    print(*b, sep='')

Solution (Python):

import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W = lr()
B = np.array([list(sr()) for _ in range(H)])
A = [[1 if x == '
row = np.sum(A, axis=1)
column = np.sum(A, axis=0)
r = row != 0
c = column != 0
answer = B[r]
answer = answer[:, c].tolist()
for a in answer:
    print(''.join(a))

Solution (Python):
def rotate_matriz(s, x, y):
    ex = [[""] * x for _ in range(y)]
    for i in range(x):
        for j in range(y):
            ex[j][i] = s[i][j]
    return ex


def pprint(s, n):
    for i in range(n):
        print("".join(s[i]))


def check(s, n):
    ex = []
    ct = 0
    for i in range(n):
        if "
            ex.append(s[i][:])
        else:
            ct += 1
    return ex, n - ct


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

Solution (Python):
H, W = map(int, input().split())
A = []
count = 0
for i in range(H):
    tmp = input() 
    if tmp == '.' * W:
        count += 1
    else:
        A.append(tmp)

skipp = []
for j in range(W):
    coucou = 0
    for i in range(H - count):
        if A[i][j] == '
            coucou = 1
            break
    if coucou == 0:
        skipp.append(j)
        

for i in range(H-count):
    for j in range(W):
        if j not in skipp:
            print(A[i][j], end = '')
    print()

Solution (Python):
from functools import reduce

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

A = []
is_colm_black = [True] * W
for _ in range(H):
    a = list(input())
    if DEBUG:
        print("a: {}".format(a))
    if not reduce(lambda x, y: x and (y == "."), a, True):
        A.append(a)
        for i, j in enumerate(a):
            is_colm_black[i] &= (j == '.')

if DEBUG:
    print("A: {}".format(A))
    print("is_colm_black: {}".format(is_colm_black))

ans = []
for i in range(len(A)):
    a = ""
    for j, f in enumerate(is_colm_black):
        if not f:
            a += A[i][j]
    if a:
        ans.append(a)
    if DEBUG:
        print("i: {}, a: {}".format(i, a))
print(*ans, sep="\n")

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    h,w=map(int, input().split())
    l=[]
    for i in range(h):
        ll=list(input())
        l.append(ll)
    
    
    gyou= [False] * w
    retu= [False] * h
    
    for retunum in range(h):
        
        for gyounum in range(w):
            
            
            if l[retunum][gyounum]=='
                retu[retunum]=True
                gyou[gyounum]=True
    
    for retunum in range(h):
        if retu[retunum]:
            for gyounum in range(w):
                if gyou[gyounum]:
                    
                    print(l[retunum][gyounum],end='')
            
            print('')
resolve()