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

for _ in range(H):
  x = input()
  if x != "."*W:
    grid.append(x)

h = len(grid)
Flag = [True]*W

for j in range(W):
  if all(grid[i][j] == "." for i in range(h)):
    Flag[j] = False

for i in range(h):
  print("".join([grid[i][j] for j in range(W) if Flag[j]]))

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

for _ in range(H):
  x = input()
  if x != "."*W:
    grid.append(x)

h = len(grid)
Flag = [True]*W

for j in range(W):
  if all([grid[i][j] == "." for i in range(h)]):
    Flag[j] = False

for i in range(h):
  print("".join([grid[i][j] for j in range(W) if Flag[j]]))

Solution (Python):
import numpy as np
H,W = map(int,input().split())
grid = []
for i in range(H):
    mojiretsu = input()
    moji = []
    for k in range(len(mojiretsu)):
        moji.append(mojiretsu[k])
    grid.append(moji)
grid = np.array(grid)
flug1 = True
flug2 = True
flug3 = False
flug4 = False
while flug1:
    for i in range(grid.shape[0]):
        if np.all(grid[i,:] == "."):
            grid = np.delete(grid, i, 0)
            flug3 = False
            break
        else:
            flug3 = True
    if flug3 == True:
        flug1 = False
while flug2:
    for j in range(grid.shape[1]):
        if np.all(grid[:,j] == "."):
            grid = np.delete(grid, j, 1)
            flug4 = False
            break
        else:
            flug4 = True
    if flug4 == True:
        flug2 = False
for height in range(grid.shape[0]):
    print("".join(list(grid[height,:])))

Solution (Python):









import os
import sys
import numpy as np



def main():
    h, w = map(int, input().split())
    a = np.zeros((h,w), dtype = np.int32)
    for i in range(h):
        s = input()
        for j in range(w):
            if s[j] == '.':
                a[i, j] = 1
    stack = []
    delete_colums = 0
    delete_index = 0
    for i in range(h):
        if np.sum(a[i, :]) == w:
            stack.append(i)
            delete_index += 1
    while stack:
        p = stack.pop()
        a = np.delete(a, obj=p, axis=0)

    for i in range(w):
        if np.sum(a[:, i]) == h-delete_index:
            stack.append(i)
            delete_colums += 1
    while stack:
        p = stack.pop()
        a = np.delete(a, obj=p, axis=1)
    
    for i in range(h-delete_index):
        for j in range(w-delete_colums):
            if a[i, j] == 0:
                print('
            else:
                print('.', end='')
        print()
            



if __name__ == "__main__":
    main()

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

for i in range(H):
    if A[i] == ['.'] * W:
        A[i] = ['-1'] * W
for j in range(W):
    count = 0
    for i in range(H):
        if A[i][j] == '
            break
        count += 1
    if count == H:
        for i in range(H):
            A[i][j] = '-1'
for a in A:
    if a == ['-1'] * W:
        continue
    ans = [ai for ai in a if not ai == '-1']
    print(''.join(ans))

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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



grid = []
black = [0] * W
for i in range(H):
    a = readline().decode().rstrip()
    if a.count('
        grid.append(a)
        for j in range(W):
            if a[j] == '
                black[j] = 1


for a in grid:
    s = ''
    for j in range(W):
        if black[j] == 1:
            s += a[j]
    print(s)

Solution (Python):

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


for i in reversed(range(H)):
        if a[i].count(".") == W:
            a.pop(i)


H = len(a)


for i in reversed(range(W)):
    for j in range(H):
        if a[j][i] == ".":
            pass
        else:
            break
    else:
        for j in range(H):
            a[j].pop(i)


for i in range(H):
    a[i] = "".join(a[i])
    print(a[i])

Solution (Python):

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

for i in range(H):
	a = input()
	
	if '
		grid.append(a)

ans = [''] * len(grid)

for i in range(W):
	count = 0
	
	for j in range(len(grid)):
		if grid[j][i] == '
			count += 1
	
	if count > 0:
		for j in range(len(grid)):
			ans[j] += grid[j][i]

for a in ans:
	print(a)

Solution (Python):
h,w = map(int,input().split())
a = []
for i in range(h):
    b = input()
    if len(set(b)) > 1 or b[0] == '
        a.append(b)
c = list(range(w))
for i in range(w):
    f = 0
    for j in range(len(a)):
        if a[j][i] == '
            f = 1
            break
    if f == 0:
        c.remove(i)

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

Solution (Python):


def solve(h,w,a):
  h_flags = [True]*h
  w_flags = [False]*w
  for i in range(h):
    if not "
      h_flags[i] = False
    for j in range(w):
      if a[i][j] == "
        w_flags[j] = True
  for i in range(h):
    if not h_flags[i]:
      continue
    for j in range(w):
      if w_flags[j]:
        print(a[i][j],end="")
    print("")
  return 



def main():
  H,W = map(int,input().split())
  a = [input() for _ in range(H)]
  solve(H,W,a)
  return

if __name__ == '__main__':
  main()

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

b = list(zip(*a))

for i in range(h):
    if a[i].count('
        H[i] = 1

for i in range(w):
    if b[i].count('
        W[i] = 1

c = []
for i in range(h):
    tmp = []
    for j in range(w):
        if H[i] == 1 and W[j] == 1:
            tmp.append(a[i][j])
    if tmp != []:
        c.append(tmp)

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

Solution (Python):
import math
def main():
  h,w = list(map(int,input().split()))
  a = [input() for i in range(h)]
  ans=0
  i=0
  while i<h:
    if '
      a.pop(i)
      h=h-1
      i-=1
    i+=1
  i=0
  while i<w:
    for j in range(0,h):
      if a[j][i]=='
        break
      elif j==h-1:
        for k in range(0,h):
          a[k]=a[k][:i]+a[k][i+1:]
        w-=1
        i-=1
    i+=1
  for i in range(0,h):
    print(a[i])
main()

Solution (Python):
H,W=map(int,input().split())
f=lambda S,L:"".join(map(lambda x:S[x],L))
S=[]

B=[]
for w in range(H):
    K=input()
    S.append(K)

    if K.count("
        B.append(w)
        

A=[]
for x in range(W):
    F=False
    for y in range(H):
        F|=(S[y][x]=="

    if F:
        A.append(x)
        
T=[]
for b in B:
    T.append(f(S[b],A))
print("\n".join(T))

Solution (Python):
def elimrow(lst):
    lst_after = []
    gset = []
    H1 = len(lst)
    for i in range(H1):
        gset = list(set(lst[i]))
        gset.sort()
        
        if gset[0] != '.':
            lst_after.append(lst[i])
    return lst_after

def trans(lst):
    return list(zip(*lst))

def main():
    H,W = map(int,input().split())

    grid = [list(str(input())) for _ in range(H)]
    grid_after = []
    grid_after = elimrow(grid)
    gridT = trans(grid_after)
    grid_after2 = elimrow(gridT)
    gridT2 = trans(grid_after2)
    
    for i in gridT2:
        print(*i,sep='')

if __name__ == "__main__":
    main()

Solution (Python):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    h, w = map(int, input().split())
    a = []
    row_ng = ['.'] * w
    for _ in range(h):
        row = list(input())
        if row == row_ng:
            h -= 1
        else:
            a.append(row)

    a2 = [[] for _ in range(h)]
    for i1 in range(w):
        flag = False
        for i2 in range(h):
            if a[i2][i1] == '
                flag = True
                break
        if flag:
            for i3 in range(h):
                a2[i3].append(a[i3][i1])

    for arow in a2:
        print("".join(arow))

if __name__ == '__main__':
    main()

Solution (Python):
h,w = map(int,input().split())
ch = []
for i in range(h):
    a = str(input())
    if "
        ch.append(a)
h = len(ch)
bit = [0]*w
for i in range(h):
    for j in range(w):
        if ch[i][j] == "
            bit[j] = 1

for i in range(h):
    ans = ""
    for j in range(w):
        ans += ch[i][j]*bit[j]
    print(ans)

Solution (Python):
h, w = map(int,input().split())
maps = [None]*h
for i in range(h):
    maps[i] = input()
hashes = []
for i in range(h):
    if "
        hashes.append(i)
white = []
for i in range(w):
    flag = 0
    for j in range(h):
        if maps[j][i] == "
            flag = 1
    if flag == 1:
        white.append(i)
for i in hashes:
    for j in white:
        print(maps[i][j],end="")
    print()

Solution (Python):
h,w = map(int,input().split())
grid = [list(input()) for i in range(h)]
row = {}
col = {}

for i in range(h):
    if "
        row[i] = True
    else:
        row[i] = False

for j in range(w):
    c = False
    for i in range(h):
        if grid[i][j] == "
            c = True
    else:
        if c:
            col[j] = True
        else:
            col[j] = False

for i in range(h):
    o = False
    for j in range(w):
        if row[i] and col[j]:
            print (grid[i][j], end="")
            o = True
            pass
        else:
            pass
    if o:
        print ()

Solution (Python):
H, W = map(int, input().split())
grid = [input() for _ in range(H)]
Hs = set()
Ws = set()
for h in range(H):
  for w in range(W):
    if grid[h][w] == "
      Hs.add(h)
      Ws.add(w)
Hs = sorted(list(Hs))
Ws = sorted(list(Ws))
for h in Hs:
  for w in Ws:
    print(grid[h][w], end="")
  print()

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


for i in range(len(A)-1, -1, -1):
  if A[i].count(".") == len(A[i]):
        A.pop(i)

rm = []

for w in range(W):
  f = True
  for h in range(len(A)):
    if A[h][w] == "
        f = False
  if f:
    rm.append(w)

for r in range(len(rm)-1, -1, -1):
  for h in range(len(A)):
      A[h] = A[h][:rm[r]] + A[h][rm[r]+1:]


for a in A:
  print(a)

Solution (Python):
H, W = map(int, input().split())
A = [list(input()) for i in range(H)]
hi_list = []
wj_list = []
for i in range(H):
    c = 0
    for j in range(W):
        if A[i][j] == '.':
            c += 1
    if c == W:
        hi_list += [i]
for j in range(W):
    c = 0
    for i in range(H):
        if A[i][j] == '.':
            c += 1
    if c == H:
        wj_list += [j]

hi_set = set(hi_list)
wj_set = set(wj_list)
for i in range(H):
    if i in hi_set:
        continue
    for j in range(W):
        if j in wj_set:
            continue
        print(A[i][j], end='')
    print()

Solution (Python):
H,W = map(int,input().split())
L = []
for h in range(H):
  L.append(input())
  
X = [0]*W
Y = [0]*H

for h in range(H):
  for w in range(W):
    if L[h][w]=="
      X[w]=1
      Y[h]=1
      
for h in range(H):
  if Y[h]==1:
    for w in range(W):
      if X[w]==1:
        print(L[h][w] , end="")
    print()

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue

from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

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


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    H, W = il()
    HW = [sl() for _ in range(H)]
    h = [False] * H
    w = [False] * W

    for n in range(H):
        hw = HW[n]
        if '
            h[n] = True
        for m in range(W):
            if hw[0][m] == '
                w[m] = True

    for n in range(H):
        if h[n]:
            str = ''
            for m in range(W):
                if w[m]:
                    str += HW[n][0][m]
            print(str)


if __name__ == '__main__':
    main()

Solution (Python):
H, W = map(int,input().split())
l = []
for h in range(H):
    s = list(input())
    if s != ["."]*W:
        l.append(s)

for w in range(W-1, -1, -1):
    cnt = 0
    for h in range(len(l)):
        if l[h][w] == "
            break
        else:
            cnt += 1
    if cnt == len(l):
        for h in range(len(l)):
            del l[h][w]
for h in range(len(l)):
    print("".join(l[h]))

Solution (Python):

import sys
from collections import defaultdict, deque




def solve():
    n, m = [int(x) for x in input().split()]
    s = []
    ii = []
    jj = []
    cols = [[] for _ in range(m)]
    for i in range(n):
        r = [x for x in input()]
        if '
            ii.append(i)
        for j in range(m):
            cols[j].append(r[j])
        s.append(r)
    for j in range(m):
        if '
            jj.append(j)
    
    for i in range(n):
        if i in ii:
            continue
        for j in range(m):
            if j in jj:
                continue
            print(s[i][j], end='')
        print()


t = 1

for case in range(1,t+1):
    ans = solve()

"""

"""

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

grid = [""]*W

for _ in range(H):
    tmp = input()
    if "."*W != tmp:
        for i, x in enumerate(tmp):
            grid[i] += x
j = len(grid[0])
ans = [""]*j
for row in grid:
    if "."*j != row:
        for i, s in enumerate(row):
            ans[i] += s


for r in ans:
    print(r)

Solution (Python):
import numpy as np

H, W, *M = open(0).read().split()
H = int(H)
W = int(W)
M = np.array([list(r) for r in M])

del_rows = []

M_ans = M

for i in range(H):
    if "
         del_rows.append(i)
            
M_ans = np.delete(M_ans, del_rows, 0)

del_cols = []

for j in range(len(M_ans.T)):
    if "
         del_cols.append(j)
            
M_ans = np.delete(M_ans, del_cols, 1)

print(*["".join(r) for r in M_ans], sep="\n")

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

row = []
col = []
for i in range(h):
  if a[i].count(".") != w: row.append(i)
for i in range(w):
  t = 0
  for j in range(h):
    if a[j][i] == ".": t+=1
  if t != h: col.append(i)

for i in row:
  ans = ""
  for j in col:
    ans += a[i][j]
  print(ans)

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

    for i in range(h):
        f = True
        for j in range(w):
            if a[i][j] != ".":
                f = False
                break
                print(i, "breaked")
        if f:
            loop_flag = True
            a.pop(i)
            h -= 1
            break
            
    

    for j in range(w):
        f = True 
        for i in range(h):
            
            if a[i][j] != ".":
                f = False
                break
        if f:
            loop_flag = True
            for i in range(h):
                a[i].pop(j)
            w -= 1
            break
        
for i in range(h):
    print("".join(a[i]))

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

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

line = []
colu = []
for i in range(H):
    for j in range(W):
        if a[i][j] == '
            line.append(i)
            colu.append(j)

ans=[]
for i in range(H):
    dammy=[]
    for j in range(W):
        if (i in line) and (j in colu):
            dammy.append(a[i][j])
    if dammy!=[]:
        ans.append(dammy)

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

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

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

line = [0]*H
colu = [0]*W
for i in range(H):
    for j in range(W):
        if a[i][j] == '
            line[i]=1
            colu[j]=1

ans=[]
for i in range(H):
    dammy=[]
    for j in range(W):
        if line[i]==1 and colu[j]==1 :
            dammy.append(a[i][j])
    if dammy!=[]:
        ans.append(dammy)

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

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

for i in range(H):
    M.append(list(input()))

Hs = []
for i in range(H):
    flag = 0
    for j in range(W):
        if M[i][j]!=".":
            flag = 1
    if flag==1:
        Hs.append(i)

Ws = []
for j in range(W):
    flag = 0
    for i in range(H):
        if M[i][j]!=".":
            flag = 1
    if flag==1:
        Ws.append(j)

for i in Hs:
    out = []
    for j in Ws:
        out.append(M[i][j])
    print("".join(out))

Solution (Python):

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

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



line = []
colu = []
for i in range(H):
    for j in range(W):
        if a[i][j] == '
            line.append(i)
            colu.append(j)



ans=[]
for i in range(H):
    dammy=[]
    for j in range(W):
        if (i in line) and (j in colu):
            dammy.append(a[i][j])
    if dammy!=[]:
        ans.append(dammy)

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

Solution (Python):
import numpy as np
h, w = map(int, input().split())
board = [list(str(input())) for _ in range(h)]
for j in range(2):
    board = [i for i in board if i.count('
    board = np.array(board)
    board = board.T
    board = board.tolist()
for i in board:
    print(*i, sep='')

Solution (Python):
import numpy as np
h, w = map(int, input().split())
grid = [list(input()) for _ in range(h)]
grid2 = []
ans = []
cur = 0
for a in grid:
    if "
        grid2.append(a)
t_grid2 = np.array(grid2).T.tolist()
for a in t_grid2:
      if "
        ans.append(a)
ans = np.array(ans).T.tolist()
for i in range(len(ans)):
  out = "".join(ans[i])
  print(out)

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

l = []
ll = [[True for i in range(w)] for j in range(h)]
for _ in range(h):
    s = input()
    cells = list(s)
    
    l.append(cells)
    


for h_i in range(h):
    flag = True
    for w_i in range(w):
        
        if l[h_i][w_i] == "
            flag = False
            break
    if flag:
        for w_i in range(w):
            ll[h_i][w_i] = False

for w_i in range(w):
    flag = True
    for h_i in range(h):
        
        if l[h_i][w_i] == "
            flag = False
            break
    if flag:
        for h_i in range(h):
            ll[h_i][w_i] = False
            


for i in range(h):
    lll = []
    for j in range(w):
        
        if ll[i][j]:
            lll.append(l[i][j])
    if len(lll) > 0:
        print(''.join(lll))

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

H_idx=[]
for i in range(H):
    count = 0
    for j in range(W):
        if a[i][j]=='.':
            count +=1
    if count != W:
        H_idx.append(i)

W_idx=[]
for i in range(W):
    count = 0
    for j in range(H):
        if a[j][i]=='.':
            count +=1
    if count != H:
        W_idx.append(i)

for i in H_idx:
    ans = ''
    for j in W_idx:
        ans +=a[i][j]
    print(ans)

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

hh = []
for y in range(h):
    f = True
    for x in range(w):
        if a[y][x] == '
            f = False
            break
    if f:
        hh.append(y)

ww = []
for x in range(w):
    f = True
    for y in range(h):
        if a[y][x] == '
            f = False
            break
    if f:
        ww.append(x)

ans = []
for y in range(h):
    if y in hh:
        continue
    aa = ''
    for x in range(w):
        if x in ww:
            continue
        aa += a[y][x]
    ans.append(aa)

for aa in ans:
    print(aa)

Solution (Python):
import numpy as np

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

A = []
for i in G:
    if not '
        continue
    A.append(i)

B = np.array(A)
B = B.T

X = []
for i in B:
    if not '
        continue
    X.append(i)

ans = np.array(X)
ans = ans.T

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

Solution (Python):
h,w = map(int, raw_input().split())
mat = [list(raw_input()) for _ in range(h)]
rows = set([i for i in range(len(mat)) if '

cols = set([i for i in range(len(mat[0])) if '

mat = [mat[i] for i in range(len(mat)) if i in rows]


mat = [[mat[i][j] for j in range(len(mat[0])) if j in cols] for i in range(len(mat))]

for l in mat:
	print ''.join(l)

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0
inf = float("inf")

h,w = I()
board = [X() for _ in range(h)]
num = []
nn = []

for i in range(h):
    if "
        num.append(i)

for i in num:
    a = i - count
    del board[a]
    count += 1

for i in range(w):
    nn.append(i)
    for j in range(len(board)):
        if board[j][i] == "
            nn.remove(i)
            break

for i in range(len(board)):
    cnt = 0
    for j in nn:
        b = j-cnt
        del board[i][b]
        cnt += 1

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

Solution (Python):
import numpy as np
h, w = map(int, input().split())
field = [list(input()) for _ in range(h)]


np_field = np.array(field)
cols = np.logical_not(np.all(np_field=='.', axis=0))
rows = np.logical_not(np.all(np_field=='.', axis=1))

ans = np_field[np.ix_(rows, cols)]

for a in ans:
    print(''.join(map(str, a)))

Solution (Python):
H, W = map(int, input().split())
L = []
brank = "." * W
for _ in range(H):
  S = input()
  if S == brank:
    continue
  L.append(list(map(str, S)))

if L:
  L1 = list(zip(*L))
  brank = tuple(["." for _ in range(len(L1[0]))])
  ans = []

  for l in L1:
    if l == brank:
      continue
    ans.append(l)


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

Solution (Python):
H, W = map(int, input().split())
L = []
brank = "." * W
ban = []
for _ in range(H):
  s = input()
  if brank == s:
    continue
  L.append(list(map(str, s)))
  
for i in range(W):
  for l in L:
    if l[i] != ".":
      break
  else:
    ban.append(i)
    continue

for l in L:
  ans = ""
  for i in range(W):
    if i in ban:
      continue
    ans += l[i]
  print(ans)

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

H,W = list(map(int,input().split()))
cell = []
for i in range(H):
    s=list(input().rstrip())
    cell.append(s)
h = set(range(H))
w = set(range(W))
sh = []
sw = []
for ih in range(H):
    for iw in range(W):
        if cell[ih][iw] == '
            sh.append(ih)
            sw.append(iw)
sh = set(sh)
sw = set(sw)
for iih in sh:
    for iiw in sw:
        print(cell[iih][iiw],end='')
    print('')

Solution (Python):
h, w = map(int, input().split())
a = [''] * h
for i in range(h):
	a[i] = input()
 
row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if a[i][j] == '
			row[i] = True
			col[j] = True
 
for i in range(h):
	if row[i]:
		for j in range(w):
			if col[j]:
				print(a[i][j], end = '')
		print()

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

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

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

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



for i in range(H):
    tmp = []
    for j in not_removedW:
        tmp.append(a[i][j])
    a[i]=tmp

for i in not_removedH:
    print("".join(a[i]))

Solution (Python):
h,w = map(int,input().split())
a = [list(input()) for i in range(h)]
hl = [0] * h
wl = [0] * w
for i in range(h):
    if '
        hl[i] = 1
        for j in range(w):
            if a[i][j] == '
                wl[j] = 1

for i in range(h):
    t = []
    for j in range(w):
        if  hl[i] == 1 and wl[j] == 1:
            t.append(a[i][j])
    if len(t) != 0:
        print(''.join(t))

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

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

a2=[i for i in a if '
a3=[i for i in zip(*a2) if '
for i in zip(*a3):
  print(''.join(i))

Solution (Python):
h, w, *a = open(0).read().split()
for _ in range(2):
    a = [list(j) for j in zip(*[i for i in a if "
print(*["".join(i) for i in a], sep="\n")

Solution (Python):

h, w = map(int, input().split())
a = [[i for i in input()] for _ in range(h)]
a = [i for i in a if "
a = [list(i) for i in zip(*a)]
a = [i for i in a if "
a = [list(i) for i in zip(*a)]
a = ["".join(i) for i in a]
print(*a, sep="\n")

Solution (Python):
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

INF = 10**18
eps = 10**-7

H,W = map(int,readline().split())
a = [readline().rstrip() for i in range(H)]

h = [True] * H
w = [True] * W

for i in range(H):
    if a[i] == "."*W:
        h[i] = False
for i in range(W):
    if all(a[j][i] == "." for j in range(H)):
        w[i] = False
ans = []
for i in range(H):
    s = ""
    for j in range(W):
        if h[i] and w[j]:
            s += a[i][j]
    if s != "":
        print(s)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

H, W = mapint()
query = [list(input()) for _ in range(H)]

rows = [0]*H
cols = [0]*W
for h in range(H):
    for w in range(W):
        if query[h][w]=='
            rows[h] = 1
            cols[w] = 1

for h in range(H):
    if not rows[h]:
        continue
    ans = []
    for w in range(W):
        if cols[w]:
            ans.append(query[h][w])
    print(''.join(ans))

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

H,W = I()
maze = [list(s()) for _ in range(H)]
L1 = []
for i in range(H-1,-1,-1):
    if '
        maze.pop(i)
H = len(maze)
L2 = []
for i in range(W-1,-1,-1):
    Flag = 1
    for j in range(H):
        if maze[j][i] == '
            Flag = 0
            break
    if Flag:
        for j in range(H):
            maze[j].pop(i)
for i in range(H):
    print(''.join(maze[i]))

Solution (Python):
h,w=map(int,input().split())
norow=set()
nocolumn=set()
s=[]
for i in range(h):
  a=input()
  s.append(a)
for i in range(h):
  flag=0
  for j in range(w):
    if s[i][j]=='
      flag=1
  if flag==0:
    norow.add(i)
for j in range(w):
  flag=0
  for i in range(h):
    if s[i][j]=='
      flag=1
  if flag==0:
    nocolumn.add(j)
for i in range(h):
  if i in norow:
    continue
  ans=[]
  for j in range(w):
    if j in nocolumn:
      continue
    ans.append(s[i][j])
  print(''.join(ans))

Solution (Python):
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

INF = 10**18
eps = 10**-7

H,W = map(int,readline().split())
a = [readline().rstrip() for i in range(H)]

h = [True] * H
w = [True] * W

for i in range(H):
    if a[i] == "."*W:
        h[i] = False
for i in range(W):
    if all(a[j][i] == "." for j in range(H)):
        w[i] = False
ans = []
for i in range(H):
    s = ""
    for j in range(W):
        if h[i] and w[j]:
            s += a[i][j]
    if s != "":
        ans.append(s)
for s in ans:
    print(s)

Solution (Python):
h,w = map(int,input().split())
k = []
h_remove = []
w_remove = []
for i in range(h):
    ls = input()
    if ls.count(".") == w:
        h_remove.append(i)
    k.append(ls)
for i in range(w):
    now = ""
    for j in range(h):
        now += k[j][i]
    if now.count(".") == h:
        w_remove.append(i)
h_remove = set(h_remove)
w_remove = set(w_remove)
for i in range(h):
    ans = ""
    if i in  h_remove:
        continue
    else:
        for j in range(w):
            if j in w_remove:
                continue
            else:
                ans += k[i][j]
        print(ans)

Solution (Python):
H,W = map(int,input().split())
A = [list(input()) for _ in range(H)]
B = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    for j in range(W):
        if A[i][j]=="
            B[i][j] = 1
C = []
for i in range(H-1,-1,-1):
    if sum(B[i])==0:
        C.append(i)
B1 = []
for i in range(H):
    if i not in C:
        B1.append(B[i])
C = []
for j in range(W):
    flag = 0
    for i in range(len(B1)):
        if B1[i][j]==1:
            flag = 1
            break
    if flag==0:
        C.append(j)
B2 = []
for i in range(len(B1)):
    row = []
    for j in range(W):
        if j not in C:
            row.append(B1[i][j])
    B2.append(row)
B3 = []
for i in range(len(B2)):
    x = ""
    for j in range(len(B2[i])):
        if B2[i][j]==0:
            x += "."
        else:
            x += "
    B3.append(x)
for i in range(len(B3)):
    print(B3[i])

Solution (Python):
def resolve():
  h, w = map(int, input().split())
  a = []
  for i in range(h):
    s = input()
    if '
      a.append(s)
  h = len(a)
  blk_clm = set()  
  for i in range(h):
    for j in range(w):
      if a[i][j] == '
        blk_clm.add(j)

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

  return

if __name__ == "__main__":
  resolve()