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

Hcnt = [0] * H
Wcnt = [0] * W

L = [list(input()) for _ in range(H)]

for i, s in enumerate(L):
  for j, c in enumerate(s):
    if c == "
      Hcnt[i] += 1
      Wcnt[j] += 1

for i, s in enumerate(L):
  if Hcnt[i] <= 0:
    continue
  for j, c in enumerate(s):
    if Wcnt[j] > 0:
      print(c, end="")
  print()

Solution (Python):
H, W = map(int, input().split())
a = [input() for i in range(H)]
 
a = ["".join(row) for row in zip(*a) if row.count("
a=  ["".join(row) for row in zip(*a) if row.count("
 
print("\n".join(a))

Solution (Python):
h, w =  [ int(v) for v in input().split() ]
column_list = []
row_list = []
field = [ None for i in range(h) ]
space_column = "." * w
space_row = "." * h
for i in range(h):
	s = input()
	field[i] = s
	if s != space_column:
		column_list.append(i)

for i in range(w):
	s = "".join([field[j][i] for j in range(h)])
	if s != space_row:
		row_list.append(i)


for i in column_list:
	print("".join([ field[i][j] for j in row_list ]))

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

grid = []

for _ in range(h):
    line = input().rstrip()
    if line.count('
        continue
    grid.append(line)


remove_columns = []

for c in range(w):
    for r in range(len(grid)):
        if grid[r][c] == '
            break
    else:
        remove_columns.append(c)

for line in grid:
    for i, l in enumerate(line):
        if i not in remove_columns:
            print(l, 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=[]
for i in range(H):
  a=input()
  A.append(a)
aw_h=[]
aw_v=[]
for i in range(H):
  if '
    aw_h.append(i)
for i in range(len(aw_h)):
  A.pop(aw_h[i]-i)
for i in range(W):
  count=0
  for j in range(len(A)):
    if A[j][i]=='.':
      count+=1
  if count==len(A):
    aw_v.append(i)
for i in range(len(A)):
  for j in range(len(aw_v)):
    A[i]=A[i][:aw_v[j]-j]+A[i][aw_v[j]-j+1:]
for i in range(len(A)):
  print(str(A[i]))

Solution (Python):
a,b=map(int,input().split())
c=[]
for i in range(a):
  g=input()
  if "
    continue
  d=list(g)
  c.append(d)
l=len(c)
p=[]
for i in range(b):
  for j in range(l):
    if c[j][i]=="
      p.append(i)
      break
for i in range(l):
  for j in range(len(p)):
    if j == len(p)-1:
      print(c[i][p[j]])
    else:
      print(c[i][p[j]],end="")

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

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

for i in range(h):
    if '
        row[i] = True

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

for i in range(h):
    output = ''
    for j in range(w):
        if row[i] and col[j]:
            output += a[i][j]
    if not output == '':
        print(output)

Solution (Python):
h, w = map(int, input().split())
cnt = [0]*w
wRemove = 0
hRemove = 0
squares = []
hRemoveList = []
wRemoveList = []
for _ in range(h) :
        a = list(input())
        squares.append(a)
for i in range(h) :
        for j in range(w) :
                if squares[i][j] == '.' :
                        cnt[j] += 1
for i in range(w) :
        if cnt[i] == h :
                wRemove += 1
                wRemoveList.append(i)
wRemoveList.sort(reverse = True)
if not wRemoveList == [] :
        for i in range(h) :
                for j in wRemoveList :
                        del squares[i][j]
for i in range(h) :
        if squares[i] == ['.']*(w - wRemove) :
                hRemove += 1 
                hRemoveList.append(i)   
hRemoveList.sort(reverse = True)           
for i in hRemoveList :
        del squares[i]
for i in range(h-hRemove) :  
        print(''.join(squares[i]))

Solution (Python):
h,w=map(int,input().split())
a=[[j for j in input()] for i in range(h)]
for i in range(h):
  if a[i].count('.')==w:
    a[i]=[]
while [] in a:
  a.remove([])
for i in range(w):
  c=0
  for j in range(len(a)):
    if a[j][i]=='.':
      c+=1
  if c==len(a):
    for j in range(len(a)):
      a[j][i]='!'
for i in range(len(a)):
  while '!' in a[i]:
    a[i].remove('!')
for i in a:
  print(*i,sep='')

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

if "
    pages = [a]
else:
    pages = []

for i in range(h-1):
    a = input()
    if "
        pages.append(a)
    else:
        continue
    for j in box:
        if a[j] != ".":
            box.remove(j)

box.reverse()
for i in range(len(pages)):
    for j in box:
        pages[i] = pages[i][:j] + pages[i][j+1:]

    print(pages[i])

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

while '.' * W in A:
    A.remove('.' * W)

remove_j = set()
for j in range(W):
    if set([A[i][j] for i in range(len(A))]) == {'.'}:
        remove_j.add(j)

active_j = set(range(W)) - remove_j
active_j = sorted(list(active_j))
for a in A:
    print(''.join([a[j] for j in active_j]))

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

c=[]
for li in a:
    if li!=['.']*len(li):
        c.append(li)

b=[]
for lc in zip(*c):
    if lc!=('.',)*len(lc):
        b.append(lc)

for ld in zip(*b):
    print(''.join(ld))

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 = []
for i in range(h):
    a.append(input())
hh = [False]*h
ww = [False]*w
for i in range(h):
    for j in range(w):
        if a[i][j]=="
            hh[i]=True
            ww[j]=True
for i in range(h):
    if hh[i]:
        for j in range(w):
            if ww[j]:
                print(a[i][j],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())
 
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):

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):
h,w=map(int,input().split())
l=[list(input()) for i in range(h)]
dl=[]
for i in range(h):
    if "
for i in dl[::-1]:
    del l[i]
l = [list(x) for x in zip(*l)]
dl=[]
for i in range(w):
    if "
for i in dl[::-1]:
    del l[i]
l = [list(x) for x in zip(*l)]
for i in l:print("".join(map(str,i)))

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

li = []

for i in range(h):
  wi = input()
  if wi.count('
    li.append(wi)

ans = [[0 for i in range(w)] for j in range(len(li))]
  
for i in range(w):
  line = []
  for j in range(len(li)):
    line.append(li[j][i])
  if line.count('
    for j in range(len(li)):
      ans[j][i] = line[j]

for i in ans:
  a = []
  for j in i:
    if j != 0:
      a.append(j)
  print(''.join(a))

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 = [''] * 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=[]
A=[[i for i in input()] for _ 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())
l=[list(input()) for i in range(h)]
hs=set()
ws=set()
for i in range(h):
    for j in range(w):
        if l[i][j]=="
            hs.add(i)
            ws.add(j)
for i in hs:
    for j in ws:
        print(l[i][j],end="")
    print()

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

for _ in range(H):
    sd = list(input())
    if '
        a.append(sd)

col = [False] * W

for i in range(W):
    if '
        col[i] = True

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

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    h, w = f()
    lines = []
    for i in range(h):
        lines.append(input())
    
    rl = set()
    rc = set()
    for i in range(h):
        for j in range(w):
            if lines[i][j]== '
                rl.add(i)
                rc.add(j)
    
    rl = sorted(rl)
    rc = sorted(rc)

    for i in rl:
        for j in rc:
            print(lines[i][j], end = '')
        print()



solve()

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

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

Solution (Python):
H,W = list(map(int,input().split()))
b = []
if H == 1:
    print(input())
else:
    for _ in range(H):
        a = input()
        if a.count('.') == W:
            pass
        else:
            b.append(a)
    st = set()
    
    for i,c in enumerate(b[0]):
        if c == '.':
            st.add(i)
    for a in b[1:]:
        s_st = set()
        for k in st:
            if a[k] == '
                s_st.add(k)
        st -= s_st
    
    for c in b:
        for i,d in enumerate(c):
            if not i in st:print(d,end='')
        else:print('')

Solution (Python):
H, W = map(int, raw_input().split())
board = []
for i in range(0, H):
	s = raw_input()
	lst = []
	for j in range(0, W):
		lst.append(s[j])
	board.append(lst)
down = []
for i in range(0, W):
	down.append(False)
for i in range(0, H):
	for j in range(0, W):
		if board[i][j] == '
for i in range(0, H):
	if '
		outs = ''
		for j in range(0, W):
			if down[j]: outs = outs + board[i][j]
		print outs

Solution (Python):

import math
H,W = list(map(int,input().split(" ")))
mas = []
for _ in range(H):
    temp = input()
    if temp == "."*W :
        temp = "-" * W
    mas.append(list(temp))
for w in range(W):
    flag = True
    for h in range(H):
        if mas[h][w]  == "
            flag = False
            break
    if flag:
        for h in range(H):
            mas[h][w] = "-"

for h in range(H):
    flag = False
    for w in range(W):
         if mas[h][w] != "-":
            print(mas[h][w],end="")
            flag = True
    if flag:
        print()

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

H=[]
W=[]
for i in range(h):
    count=0
    for j in range(w):
        if a[i][j]==".":
            count+=1
    if count==w:
        H.append(i)
for i in range(w):
    count=0
    for j in range(h):
        if a[j][i]==".":
            count+=1
    if count==h:
        W.append(i)
for i in range(1,len(H)+1):
    for j in range(w):
        a[H[-1*i]][j]=""
for i in range(1,len(W)+1):
    for j in range(h):
        a[j][W[-1*i]]=""

for i in range(h):
    if not ("." in a[i] or "
        continue
    print("".join(a[i]))

Solution (Python):

from itertools import *


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

    A = [list(input()) for i in range(H)]
    B = list(zip(*A))

    AA = [not all(x=="." for x in a) for a in A]
    BA = [not all(x=="." for x in b) for b in B]

    for a in compress(A,AA):
        for b in compress(a,BA):
            print(b,end="")
        print("")

    
    pass

if __name__ == '__main__':
    main()

Solution (Python):





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

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

    B = list(zip(*A))

    AA = []
    for a in A:
        AA.append(all(x == "." for x in a))

    BA = []
    for b in B:
        BA.append(all(x == "." for x in b))

    for a,aa in zip(A,AA):
        if not aa:
            for b,ba in zip(a,BA):
                if not ba:
                    print(b,end="")
            print("")




    
    pass

if __name__ == '__main__':
    main()

Solution (Python):
h,w=map(int,input().split())
a=[list(input()) for i in range(h)]
hl=[]
wl=[]
for i in range(h):
    for j in range(w):
        if a[i][j]=='
            hl.append(i)
            wl.append(j)
for i in set(hl):
    for j in set(wl):
        print(a[i][j],end='')
    print()

Solution (Python):
h, w = map(int, input().split())
blankw = [True] * w
blankh = [False] * h
data = []
for i in range(h):
    s = input()
    line = []
    if s.find("
        blankh[i] = True
    for j in range(w):
        line.append(s[j])
        if s[j] == "
            blankw[j] = False
    data.append(line)

for i in range(h):
    if blankh[i] is True:
        continue
    for j in range(w):
        if blankw[j] is True:
            continue
        print(data[i][j], end="")

    print("")

Solution (Python):
h, w = map(int, input().split())
field = []
hstack, wstack = set(), set()

for i in range(h):
    a = input()
    field.append(a)
    for j in range(w):
        if a[j] == '
            hstack.add(i)
            wstack.add(j)

hstack = sorted(list(hstack))
wstack = sorted(list(wstack))

for i in hstack:
    out = ""
    for j in wstack:
        out += field[i][j]
    print(out)

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


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

Solution (Python):
import numpy as np

h, w = map(int, input().split())
grid = np.array([[j for j in input()] for i in range(h)])
grid = np.array([x for x in grid if "
grid = np.array([x for x in grid.T if "

[print("".join(x)) for x in grid.T]

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

H, W = map(int, input().split())
arr = [[j for j in input().rstrip()] for i in range(H)]
b = [x for x in arr if '
c = zip(*[x for x in zip(*b) if '
for x in c:
  print("".join(x))

Solution (Python):

"""
B - Grid Compression
https://atcoder.jp/contests/abc107/tasks/abc107_b

"""
import sys


def solve(H, W, grid):
    res = [row for row in grid if not(len(set(row)) == 1 and row[0] == '.')]
    return list(zip(*[row for row in list(reversed([list(m) for m in zip(*res)])) if not (len(set(row)) == 1 and row[0] == '.')][::-1]))


def main(args):
    H, W = map(int, input().split())
    grid = [list(input()) for _ in range(H)]
    ans = solve(H, W, grid)
    for row in ans:
        print(''.join(row))


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):
H, W = map(int, input().split())
a = []
for h in range(H):
    aw = input()
    if '
        continue
    a.append(aw)

skip = []
counter = 0
for i in range(W):
    if '
        skip.append(i)

for row in a:
    for i in range(len(row)):
        if i not in skip:
            print(row[i], end='')
    print()

Solution (Python):
h,w=map(int,input().split())
g_list=[]
w_count=[0]*w

for i in range(h):
  a=input()
  if '
    g_list.append(list(a))
    a_char=list(g_list[len(g_list)-1])
    for j in range(len(a_char)):
      if a_char[j] == '
        w_count[j] +=1

for k in range(len(w_count)):
  if w_count[len(w_count)-k-1] == 0:
    for l in range(len(g_list)):
      g_list[l].pop(len(w_count)-k-1)


for m in range(len(g_list)):
  print(''.join(g_list[m]))

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

lines = []
for j in A:
    for k in j:
        if "
            lines.append(k)
lines_t = ["".join(list(i)) for i in zip(*lines)]
B = []
for g in lines_t:
    if "
        B.append(g)
C = []
C = ["".join(list(i)) for i in zip(*B)]
for v in C:
    print(v)

Solution (Python):
import sys
h, w = map(int, sys.stdin.readline().split())
a = [input() for _ in range(h)]
ans_tmp = []
for i in range(h):
    if '
        ans_tmp.append(a[i])

not_hash_num = set()
cnt = 0
for i in range(w):
    for j in range(h):
        if a[j][i] == '
            break
        if j == h-1:
            cnt += 1
            not_hash_num.add(i)



ans = [ [] for _ in range(len(ans_tmp))]


for i in range(w):
    if i in not_hash_num:
        continue
    for j in range(len(ans_tmp)):
        ans[j].append(ans_tmp[j][i])

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

Solution (Python):
h, w = map(int, input().split())
color = []
count = 0
for i in range(h):
    tmp = input()
    if "
        count +=1
        color.append(tmp)

column_count = [0] * w
for i in range(count):
    for j in range(w):
        if color[i][j] ==".":
            column_count[j]+=1

show_index = [i for i in range(len(column_count)) if column_count[i]<count]            
for i in range(count):
    content = ""
    for j in show_index:
        content += color[i][j]
    print(content)

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

a = []
for i in range(H):
    tmp = input()
    if tmp != '.'*len(tmp):
        a.append(tmp)

b = ['' for i in range(len(a))]
for i in range(W):
    check = 0
    for j in range(len(a)):
        if a[j][i] == '
            check = 1
            break
    
    if check == 1:
        for j in range(len(a)):
            print()
            b[j] += a[j][i]


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

Solution (Python):
H,W = (int(i) for i in input().split())
li = []
for i in range(H):
    li.append(input())
gyou = [False for i in range(H)]
retsu = [False for i in range(W)]
for i in range(H):
    if '
        gyou[i] = True
        for j in range(W):
            if list(li[i])[j] == '
                retsu[j] = True
for i in range(H):
    l = []
    if gyou[i] == True:
        for j in range(W):
            if retsu[j] == True:
                l.append(list(li[i])[j])
    print(''.join(l))

Solution (Python):

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

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


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

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

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

lst = []
for i in range(H):
    lst += [list(input())]

arr = np.array(lst)

lstH = []
for i in range(H):
    if all(arr[i,:] == '.'):
        lstH += [i]

arr = np.delete(arr, lstH, 0)

lstW = []

for j in range(W):
    if all(arr[:,j] == '.'):
        lstW += [j]

arr = np.delete(arr, lstW, 1)

for k in arr:
    for l in k:
        print(l, end = '')
    print()

Solution (Python):
import numpy as np
h,w=map(int,input().split())
a=np.array([[0 if x=='.' else 1 for x in input()] for _ in range(h)])
f=True
while(f):
    f=False
    i=0
    while(i<a.shape[0]):
        if np.sum(a[i])==0:
            f=True
            a=np.delete(a,i,0)
        i+=1
    i=0
    while(i<a.shape[1]):
        if np.sum(a[:,i])==0:
            f=True
            a=np.delete(a,i,1)
        i+=1
a=[list(x) for x in list(a)]
a=[['.' if x==0 else '
for i in range(len(a)):
    print(''.join(a[i]))

Solution (Python):
import sys

H, W = (raw_input()).split()
H = int(H)
W = int(W)

grid = []
for i in range(H):
    grid.append(raw_input())

new_grid = []
for i in range(H):
    if ('.'*W) != grid[i]:
        new_grid.append(grid[i])

for j in range(W):
    all_blanks = True
    for i in range(len(new_grid)):
        if new_grid[i][j] != '.':
            all_blanks = False
            break

    if all_blanks:
        for i in range(len(new_grid)):
            new_grid[i] = new_grid[i][:j] + 'b' + new_grid[i][j+1:]


for i in range(len(new_grid)):
    for j in range(W):
        if new_grid[i][j] != 'b':
            sys.stdout.write(new_grid[i][j])
    print

Solution (Python):

h, w = map(int, input().split())
lines = []
for i in range(h):
    line = input()
    if "
        lines.append(line)
lines_t = ["".join(list(i)) for i in zip(*lines)]
lines2 = []
for line in lines_t:
    if "
        lines2.append(line)
lines = ["".join(list(i)) for i in zip(*lines2)]
for line in lines:
    print(line)

Solution (Python):
h,w=map(int,input().split())
board = []
for _ in range(h):
    row = input()
    if '
        board.append(row)
result = [''] * len(board)
for i in range(w):
    if any(row[i] == '
        result = [result[j] + board[j][i] for j in range(len(board))]
for rrow in result:
    print(rrow)

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





for row in mat[::]:
  if "
    mat.remove(row)


showCol = [i for i in range(W) if "


showCol = []



for i in range(W):
  for row in mat:
    if "
      showCol.append(i)
setCol = set(showCol)


print("\n".join(["".join([row[c] for c in setCol]) for row in mat]))

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

lst = []
for i in range(H):
    lst += [list(input())]

arr = np.array(lst)

lstH = []
for i in range(H):
    if all(arr[i,:] == '.'):
        lstH += [i]

arr = np.delete(arr, lstH, 0)

lstW = []
for j in range(W):
    if all(arr[:,j] == '.'):
        lstW += [j]

arr = np.delete(arr, lstW, 1)

for k in arr:
    for l in k:
        print (l, end = '')
    print ()

Solution (Python):
def main():
    h, w = map(int, input().split())
    l = [input() for i in range(h)]
    
    row = [False]*h
    col = [False]*w

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

    

if __name__=='__main__':
    main()

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

for i in range(w):
    fl = True
    for j in range(h):
        if l[j][i]=='
            fl=False
    if fl:
        idw.append(i)
for i in range(h):
    if l[i].count('
        idh.append(i)
for i in range(h):
    if i in idh:
        continue
    for j in range(w):
        if j in idw:
            continue
        print(l[i][j], end='')
    print('')

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

for i in range(w):
    fl = True
    for j in range(h):
        if l[j][i]=='
            fl=False
    if fl:
        idw.append(i)
for i in range(h):
    if l[i].count('
        idh.append(i)
for i in range(h):
    if i in idh:
        continue
    for j in range(w):
        if j in idw:
            continue
        print(l[i][j], end='')
    print('')

Solution (Python):

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

mat = [input() for _ in range(h)]


[mat.remove(row) for row in mat[::-1] if ("

showCol = [i for i in range(w) if "


print("\n".join(["".join([row[c] for c in showCol]) for row in mat]))

Solution (Python):
array = []
del_list = []

h,w = map(int, input().split())
for i in range(h):
  x = input()
  if "
    y = list(x)
    array.append(y)
for i in range(w):
  for j in range(len(array)):
    if array[j][i] == "
      break
    else:
      if j == len(array)-1:
        del_list.append(i)
final_del_list = del_list[::-1]
for i in final_del_list:
  for j in range(len(array)):
    del array[j][i]
for i in range(len(array)):
    z = "".join(array[i])
    print(z)

Solution (Python):
import numpy as np

h, w = tuple(map(int, input().split()))
matrix = np.zeros((h, w), dtype=bool)
for i in range(h):
    row = np.array(list(input()))
    matrix[i, :] = row == "."

for i in range(h)[::-1]:
    if np.all(matrix[i, :]):
        matrix = np.delete(matrix, i, 0)

for i in range(w)[::-1]:
    if np.all(matrix[:, i]):
        matrix = np.delete(matrix, i, 1)

matrix = np.where(matrix, ".", "
for row in matrix:
    for e in row:
        print(e, end="")
    print()

Solution (Python):
H,W=map(int,input().split())
A=[]
for i in range(H):
    a=input()
    A.append(a)
B=[]
for i in range(H):
    if A[i]!='.'*W:
        B.append(A[i])
C=[]
for k in range(W):
    c=[]
    for i in range(len(B)):
        c.append(B[i][k])
    C.append(c)

D=[]
for i in range(W):
    if C[i]!=['.']*len(B):
        D.append(C[i])
E=[]
for k in range(len(B)):
    e=[]
    for i in range(len(D)):
        e.append(D[i][k])
    E.append(e)

for h in range(len(E)):
    print(''.join(E[h]))

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

Solution (Python):
import numpy as np

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

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

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

ans = np.delete(np.delete(A, delete_row, 0), delete_column, 1)

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

Solution (Python):


from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance





def main():
    h, w = intin()
    alistlist = []
    for i in range(h):
        alistlist.append(input())

    new_alistlist = []
    new_h = 0
    for alist in alistlist:
        if alist != '.' * w:
            new_alistlist.append(alist)
            new_h += 1
    alistlist = new_alistlist
    h = new_h

    remove_wlist = []
    for i in range(w):
        for j in range(h):
            if alistlist[j][i] == '
                break
        else:
            remove_wlist.append(i)

    new_alistlist = []
    for alist in alistlist:
        new_alist = ''
        for i in range(w):
            if i not in remove_wlist:
                new_alist += alist[i]
        new_alistlist.append(new_alist)
    alistlist = new_alistlist

    for alist in alistlist:
        print(alist)


if __name__ == '__main__':
    main()