Problem:
 Score : 200 points    Problem Statement There is a grid of squares with H horizontal rows and W vertical columns.
The square at the i -th row from the top and the j -th column from the left is represented as (i, j) .
Each square is black or white.
The color of the square is given as an H -by- W matrix (a_{i, j}) .
If a_{i, j} is . , the square (i, j) is white; if a_{i, j} is # , the square (i, j) is black.  Snuke is compressing this grid.
He will do so by repeatedly performing the following operation while there is a row or column that consists only of white squares:   Operation: choose any one row or column that consists only of white squares, remove it and delete the space between the rows or columns.   It can be shown that the final state of the grid is uniquely determined regardless of what row or column is chosen in each operation.
Find the final state of the grid.      Constraints  1 \leq H, W \leq 100  a_{i, j} is . or # .  There is at least one black square in the whole grid.         Input Input is given from Standard Input in the following format:  H  W  a_{1, 1}...a_{1, W}  :  a_{H, 1}...a_{H, W}       Output Print the final state of the grid in the same format as input (without the numbers of rows and columns); see the samples for clarity.        Sample Input 1 4 4
##.#
....
##.#
.#.#      Sample Output 1 ###
###
.##  The second row and the third column in the original grid will be removed.       Sample Input 2 3 3
#..
.#.
..#      Sample Output 2 #..
.#.
..#  As there is no row or column that consists only of white squares, no operation will be performed.       Sample Input 3 4 5
.....
.....
..#..
.....      Sample Output 3 #       Sample Input 4 7 6
......
....#.
.#....
..#...
..#...
......
.#..#.      Sample Output 4 ..#
#..
.#.
.#.
#.#

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

cnt = 0
rb = [x.count('.') == w for x in a]
for i in range(len(rb)):
    if rb[i] is True:
        del a[i-cnt]
        cnt += 1
cnt = 0
cb = [x.count('.') == len(a) for x in zip(*a)]
for i in range(len(cb)):
    if cb[i] is True:
        for j in range(len(a)):
            del a[j][i-cnt]
        cnt += 1

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

Solution (Python):
h,w=map(int,input().split())
A=[[i for i in input()] for j in range(h)]
B=[a for a in A if "
C=[b for b in zip(*B) if "
for c in zip(*C):
  print(*c,sep="")

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

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

b = []

for i in range(h):
    if any(c == '
        b.append(a[i])



c = []
for i in range(w):
    s = ''
    for j in range(len(b)):
        s += b[j][i]
    c.append(s)


d = []

for i in range(len(c)):
    if any(c == '
        d.append(c[i])



e = []
for i in range(len(d[0])):
    s = ''
    for j in range(len(d)):
        s += d[j][i]
    e.append(s)

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

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

def main():
    H, _ = map(int, input().split())
    G = []
    for i in range(H):
        G.append(input().strip())

    while True:
        find = False
        for i in G:
            if all(j == "." for j in i):
                G.remove(i)
                find = True
                break
        for i in range(len(G[0])):
            b = True
            for j in G:
                if j[i] != ".":
                    b = False
                    break
            if b:
                find = True
                for j,k in enumerate(G):
                    G[j] = k[:i] + k[i+1:]
                break
        if not find:
            for i in G:
                print(i)
            return

if __name__ == '__main__':
    main()

Solution (Python):
h,w=map(int,input().split())
a=[[j for j in input()] for i in range(h)]
b=[x for x in a if "
c=zip(*[y for y in zip(*b) if "
for d in c:print("".join(d))

Solution (Python):
h, w = map(int, input().split())
grid = []
for i in range(h):
  s = input()
  if '
    grid.append(list(s))
h = len(grid)

for j in range(w)[::-1]:
  skip = False
  for i in range(h):
    if grid[i][j] == '
      skip = True
      break
  if not skip:
    for i in range(h):
      grid[i][j] = ''

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

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

a = [list(input()) for _ in range(H)]
a_copy = a.copy()
for cs in a_copy:
    for c in cs:
        if c == '
            break
    else:
        a.remove(cs)

a_copy = copy.deepcopy(a)
count = 0
for row in range(len(a_copy[0])):
    for line in range(len(a_copy)):
        if a_copy[line][row] == '
            break
    else:
        for line in range(len(a_copy)):
            del a[line][row - count]
        count += 1

for cs in a:
    for c in cs:
        print(c, end='')
    print()

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

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

res = [''] * len(tmp)
for col in zip(*tmp):
    if '
        for j in range(len(tmp)):
            res[j] += col[j]

print(*res, sep='\n')

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

alist1 = []
for row in alist:
  if '
    alist1.append(row)

alist2 = []
for row in zip(*alist1):
  if '
    alist2.append(row)

for row in zip(*alist2):
  print(''.join(row))

Solution (Python):


h,w=map(int,input().split())
a=[[j for j in input()] for i in range(h)]
b=[x for x in a if "
c=zip(*[y for y in zip(*b) if "
for d in c:print("".join(d))

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

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

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

Solution (Python):
import sys;from numpy import*;h,w=input().split();a=array([list(input())for _ in range(int(h))]);savetxt(sys.stdout.buffer,a[any(a=="

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

for i in range(H):
        all_white = True
        for j in range(W):
                if a[i][j] == '
                        all_white = False
        if all_white == False:
                b.append(a[i])
H = len(b)

for j in range(W):
        all_white = True
        for i in range(H):
                if b[i][j] == '
                        all_white = False
        if all_white == True:
                for i in range(H):
                        b[i][j] = ' '    

for i in range(H):
        for j in range(W):
                if b[i][j] != ' ':
                        print(b[i][j], end = '')
        print(end = '\n')

Solution (Python):
h,w = map(int,input().split())
board = []
checkColumn = [False]*h
checkRow = [False]*w
for i in range(h):
    board.append(input())

for i in range(h):
        for j in range(w):
            if board[i][j] == "
                checkColumn[i] = True
                checkRow[j] = True
for i in range(h):
    if checkColumn[i]:
        for j in range(w):
            if checkRow[j]:
                print(board[i][j],end="")
        print()

Solution (Python):
def main():
    H, W = map(int, input().split())
    A = []
    for _ in range(H):
        A.append([a for a in input()])
    removeR = []
    for i in range(H):
        if all(A[i][j] == "." for j in range(W)):
            removeR.append(i)
    removeC = []
    for j in range(W):
        if all(A[i][j] == "." for i in range(H)):
            removeC.append(j)
    B = []
    for i in range(H):
        if i not in removeR:
            temp = []
            for j in range(W):
                if j not in removeC:
                    temp.append(A[i][j])
            B.append(temp)

    return B

if __name__ == '__main__':
    B = main()
    for i in range(len(B)):
        print("".join(B[i]))

Solution (Python):
H, W = map(int, input().split())
lines = []
linesT = []
count = 0

for i in range(H):
    line = input()
    if line.count('.') == W:
        H -= 1
        continue
    else:
        lines.append(line)

for i in range(W):
    string =''
    for j in range(H):
        string += lines[j][i]
    linesT.append(string)

lines = []
for i in range(W):
    if linesT[i].count('.') == H:
        W -= 1
        continue
    else:
        lines.append(linesT[i])

ans = []
for i in range(H):
    string = ''
    for j in range(W):
        string += lines[j][i]
    ans.append(string)

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

Solution (Python):
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce


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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""

a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654


char_list = list("abcd") 



    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())


    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

if __name__ == "__main__":
    H, W = list(map(int, sys.stdin.readline().split()))
    L = [list(list(sys.stdin.readline().rstrip())) for i in range(H)]

    L = list(filter(lambda a: any(x == "
    L = list(filter(lambda a : any(x == "
    for l in zip(*L):
        print("".join(l))

Solution (Python):
import numpy
h, w = map(int, input().split())
ls = [list(input()) for _ in range(h)]
ls = numpy.array(ls)
ls = ls[numpy.any(ls == "
ls = ls[:, numpy.any(ls == "
for i in list(ls):
    print("".join(i))

Solution (Python):
import numpy as np

n,m = map(int,input().split())
out = []
for i in range(n):
    s = list(input())
    if any(c=="
        out.append(s)

out = np.array(out).T

out2=[]
for i in range(m):
    if any(c=="
        out2.append(out[i])

out2=np.array(out2).T


for line in out2:
    for i in range(len(line)-1):
        print(line[i],end="")
    print(line[-1])

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

a=[]
for _ in range(h):
    
    s=input()
    if not s.count(".")==w:
        a.append(list(s))
h=len(a)

j=0
while(j<len(a[0])):
    white_count=0
    for i in range(h):
        if a[i][j]=="
            j+=1
            break
        else:
            white_count+=1
    if white_count==h:
        for i in range(h):
            a[i]=a[i][:j] +a[i][j+1:]

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

Solution (Python):
import math
import sys
import queue
from collections import Counter
from itertools import accumulate
from fractions import gcd
from functools import reduce


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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""

a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654


char_list = list("abcd") 



    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())


    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

if __name__ == "__main__":
    H, W = list(map(int, sys.stdin.readline().split()))
    L = [list(list(sys.stdin.readline().rstrip())) for i in range(H)]

    NL = []
    for l in L:
        if "
            NL.append(l)

    
    
    L = list(zip(*NL))
    NL2 = []
    for l in L:
        if "
            NL2.append(l)

    
    L = list(zip(*NL2))
    for l in L:
        print("".join(l))

Solution (Python):
import sys
h,w=map(int,input().split())
l1=[]
l2=[]
a=[]
for i in range(h):
    l1.append(list(map(str,input())))
for i in range(len(l1)):
    if set(l1[i])!={'.'}:
        l2.append(l1[i])
for k in range(len(l2[0])):
    c=0
    for i in range(len(l2)):
        if l2[i][k]=='.':
            c+=1
            continue
        else:
            break
    if c!=len(l2):
        a.append(k)
for i in range(len(l2)):
    b=''
    for k in a:
        b+=l2[i][k]
    print(b)

Solution (Python):
def is_horizontal_same(s):
    for j in range(0, len(s)):
        if s[j] != ".":
            return False
    return True


def is_vertical_same(str_list, i):
    for j in range(0, len(str_list)):
        if str_list[j][i] != ".":
            return False
    return True


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

    str_list = []
    for i in range(0, h):
        str_list.append(input())

    while True:
        is_completed = True

        same_line_indexes = []
        for i in range(0, len(str_list)):
            if is_horizontal_same(str_list[i]):
                same_line_indexes.append(i)
                is_completed = False
        popped_cnt = 0
        for i, v in enumerate(same_line_indexes):
            str_list.pop(v - popped_cnt)
            popped_cnt += 1

        same_vertical_line_indexes = []
        for i in range(0, len(str_list[0])):
            if is_vertical_same(str_list, i):
                same_vertical_line_indexes.append(i)
                is_completed = False
        popped_cnt = 0
        for i, v in enumerate(same_vertical_line_indexes):
            for j in range(0, len(str_list)):
                org_str = str_list[j]
                str_list[j] = org_str[:v - popped_cnt] + org_str[v - popped_cnt + 1:]
            popped_cnt += 1

        if is_completed:
            break

    for i, v in enumerate(str_list):
        print(v)


main()

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

black_mark_row = set()
black_mark_col = set()
for i in range(h):
    for j in range(w):
        if a[i][j] == "
            black_mark_row.add(i)
            black_mark_col.add(j)

for i in range(h):
    flag_line = False
    for j in range(w):
        if i in black_mark_row and j in black_mark_col:
            print(a[i][j],sep="",end="")
            flag_line = True
    if flag_line:
        print()

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

del_col_idxs = set()
for i in range(w):
    for j in range(h):
        if a[j][i] == "
            break
    else:
        del_col_idxs.add(i)

for i in range(len(ans)):
    for j in range(w):
        if not j in del_col_idxs:
            print(ans[i][j],sep="",end="")
    print()

Solution (Python):
h,w=map(int,input().split())
a=[[j for j in input()] for i in range(h)]
b=[x for x in a if "
c=zip(*[y for y in zip(*b) if "
for d in c:print("".join(d))

Solution (Python):
h,w=map(int,input().split())
a=[[j for j in input()] for i in range(h)]
b=[x for x in a if "
c=zip(*[y for y in zip(*b) if "
for d in c:print("".join(d))

Solution (Python):
H, W = map(int, input().split())
matrix = [input() for i in range(H)]
matrix2 = [[i[j] for j in range(W)] for i in matrix if i != ''.join(['.'] * W)]
new_H = len(matrix2)
remove_col = ''.join(['.'] * new_H)
i = 0
while i < len(matrix2[0]):
  if ''.join([row[i] for row in matrix2]) == remove_col:
    list(map(lambda x: x.pop(i), matrix2))
  else:
    i += 1
 
print('\n'.join([''.join(i) for i in matrix2]))

Solution (Python):
H, W = [int(x) for x in input().split()]
a = [x for x in [input() for _ in range(H)] if '
w = 0
while w < len(a[0]):
  for h in range(len(a)):
    if a[h][w]=='
      w += 1
      break
  else:
    for h in range(len(a)):
      a[h] = a[h][:w] + a[h][w+1:]

for h in range(len(a)):
  print(a[h])

Solution (Python):
h,w=map(int,input().split())
a=[[j for j in input()] for i in range(h)]
b=[x for x in a if "
c=zip(*[y for y in zip(*b) if "
for d in c:
  print("".join(d))

Solution (Python):
h,w=map(int,input().split())
sij=[[x for x in input()] for _ in range(h)]
sijd=[line for line in sij if "
sijdd=zip(*[line for line in zip(*sijd) if "
for line in sijdd:
    print("".join(line))

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

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

    B = []
    for a in A:
        if a.count('
            B.append(a)
    
    B = list(map(list, zip(*B)))
    C = []
    for b in B:
        if b.count('
            C.append(b)

    C = list(map(list, zip(*C)))

    for c in C:
        print(*c, sep='')



main()

Solution (Python):
def solve():
    h, w = map(int, input().split())
    grid = list(input() for _ in range(h))
    new_grid = []
    white_columns = set([i for i in range(w)])
    for line in grid:
        if line != "." * w:
            new_grid.append(line)
            white_columns &= set([i for i, c in enumerate(line) if c == "."])
    if white_columns:
        for line in new_grid:
            new_line = "".join([c for i, c in enumerate(line) if i not in white_columns])
            print(new_line)
    else:
        print("\n".join(new_grid))


if __name__ == "__main__":
    solve()

Solution (Python):

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

Bs = [x for x in As if "
Cs = list(zip(*Bs))
Ds = [x for x in Cs if "
ret = list(zip(*Ds))

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

Solution (Python):

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

Bs = []
for a in As:
    if "
        Bs.append(a)

Cs = list(map(list, zip(*Bs)))
Ds = []
for c in Cs:
    if "
        Ds.append(c)

ret = list(map(list, zip(*Ds)))
for x in ret:
    print(*x, sep="")

Solution (Python):
import numpy as np
h,w=map(int,input().split())
grid=np.empty((h,w),dtype="<U")
for i in range(h):
    s=list(input())
    grid[i]=s

del_row=[]
del_col=[]
for i in range(h):
    if all(grid[i]=="."):
        del_row.append(i)
for j in range(w):
    if all(grid[:,j]=="."):
        del_col.append(j)
        
grid=np.delete(grid, del_row, 0)
grid=np.delete(grid, del_col, 1)

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

Solution (Python):
import math
import sys
from itertools import accumulate
from functools import reduce
import queue
from fractions import gcd

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

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""

a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654


char_list = list("abcd") 



    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())


    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  
"""

if __name__ == "__main__":
    h,w = map(int, sys.stdin.readline().split())
    a = [list(list(sys.stdin.readline().rstrip())) for i in range(h)]
    c = [list(row) for row in zip(*a)]
    b = [x for x in a if "
    c = zip(*[y for y in zip(*b) if "
    for d in c:
        print("".join(d))

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

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

c = zip(*[i for i in zip(*A) if "
for d in c:
  print("".join(d))

Solution (Python):
h,w=map(int,input().split())
l=[]
for i in range(h):
    l.append(list(input()))
wl=[]
for i in range(h):
    wf=0
    for j in range(w):
        if l[i][j]=='.':
            wf+=1
    if wf<w:
        wl.append(i)
    
hl=[]
for i in range(w):
    hf=0
    for j in range(h):
        if l[j][i]=='.':
            hf+=1
    if hf<h:
        hl.append(i)
for i in wl:
    for j in hl:
        print(l[i][j],end='')
    print()

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

Solution (Python):

H, W = map(int, input().split())
a = []
for i in range(H): 
    a.append(list(input()))
    a[i] = [0 if x == '.' else 1 for x in a[i]]


new_a = []
for i in range(H):
    if sum(a[i]) != 0:
        new_a.append(a[i])




new_a_t = [list(x) for x in zip(*new_a)]


pre_ans = []
for i in range(W):
    if sum(new_a_t[i]) != 0:
        pre_ans.append(new_a_t[i])




pre_ans = [list(x) for x in zip(*pre_ans)]



for i in range(len(pre_ans)):
    pre_ans[i] = ['
    
    print("".join(pre_ans[i]))

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

Solution (Python):
import numpy as np
h,w=input().split()
h,w=int(h),int(w)
x3=[]
for i in range(h):
    x1=input()
    if x1 !=  w*".":
        x3.append(list(x1))

x3=np.array(x3).T.tolist()
x4=[]
for i in range(w):
    if x3[i] != ["." for i in range(len(x3[i]))]:
        x4.append(x3[i])

x4=np.array(x4).T.tolist()
for i in range(len(x4)):
    for j in range(len(x4[0])):
        print(x4[i][j],end="")
    print()

Solution (Python):
import math
import copy
import sys

inputa = input().split()



a = int(inputa[0])
b = int(inputa[1])










inputList = []
inputNumList = []
for i in range(a):
    inputNum = input()
    inputNumList = list(inputNum)
    inputList.append(inputNumList)







for i in range(len(inputList)-1, -1, -1):
    flg = True
    for j in range(len(inputList[i])):
        if inputList[i][j] =="
            flg = False
            break

    if flg:
        del inputList[i]


for j in range(b-1, -1, -1):
    flg = True
    for i in range(len(inputList)):
        if inputList[i][j] == "
            flg = False
            break

    if flg:
        for i in range(len(inputList)):
            del inputList[i][j]

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

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())
grid = [list(input()) for _ in range(h)]

rows = [0] * h
for i in range(h):
    for j in range(w):
        rows[i] |= (grid[i][j] == '

cols = [0] * w
for j in range(w):
    for i in range(h):
        cols[j] |= (grid[i][j] == '

for i in range(h):
    if not rows[i]:
        continue
    for j in range(w):
        if not cols[j]:
            continue
        print(grid[i][j], end='')
    print()

Solution (Python):
h, w = map(int, input().split())
a = [input() for i 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 = [int(x) for x in input().split()]
a = [j for j in [input() for i in range(h)] if '
a = [i for i in zip(*a) if '
print('\n'.join(["".join(line) for line in zip(*a)]))

Solution (Python):
H,W = list(map(int,input().split()))
import numpy as np
A = np.zeros([H,W])
ans = np.zeros([H,W]).astype(np.unicode)
for i in range(H):
    ans[i,:] = [x for x in input()]
    A[i,:] = [1 if x=='

rw = np.all(A == 0, axis = 1)
cl = np.all(A == 0, axis = 0)

ans = ans[~rw,:]
ans = ans[:,~cl]
for i in range(ans.shape[0]):
    print("".join(ans[i,:]))

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

for y in range(h):
    a = input()
    grid.append(a)
    remove = True
    for x in range(w):
        if a[x] == "
            remove = False
            if x not in stay_x:
                stay_x.append(x)        
    if remove != True:
        stay_y.append(y)
stay_x.sort()
for y in stay_y:
    out = ""
    for x in stay_x:
        out += grid[y][x]
    print(out)

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

ans1 = []
for a in A:
    if sum(a) != 0:
        ans1.append(a)

ans2 = []
for a in zip(*ans1):
    if sum(a) != 0:
        ans2.append(a)

ans2 = [list(map(str, i)) for i in zip(*ans2)]
for a in ans2:
    print(''.join(a).replace('0', '.').replace('1', '

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



grid = list(filter(lambda r: any([i=='
grid = zip(*grid)
grid = list(filter(lambda r: any([i=='
grid = zip(*grid)
for i in grid:
    print(''.join(i))

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

Solution (Python):
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(H, W, inputs):
    delete_row = []
    i = 0
    while len(inputs) != 0 and i < len(inputs):
        is_all_white = True
        for c in inputs[i]:
            is_all_white = is_all_white and c == '.'
        if is_all_white:
            inputs.pop(i)
        else:
            i += 1
    blank_columns = {i for i in range(len(inputs[0]))}
    for row in inputs:
        for i, c in enumerate(row):
            if c != '.' and i in blank_columns:
                blank_columns.remove(i)
    for row in inputs:
        for i, c in enumerate(row):
            if i not in blank_columns:
                print(c, end='')
        print('')

    


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    [H, W] = string_to_int(input())
    ret = solve(H, W, inputs(H))

Solution (Python):
h,w = map(int,input().split())
a = [input() for i in range(h)]
cnt = 0
b = []
for i in a:
  if i.count('.') != w:
    b.append(i)
  else:
    cnt += 1
if len(b) == 1:
    print(b[0].replace('.',''))
else:
    b = list(map(list,b))
    transpose = []
    c = []
    d = []
    for i in range(len(b[0])):
        tmp = []
        for v in b:
            tmp.append(v[i])
        transpose.append(tmp)
    for i in transpose:
        c.append(''.join(i))
    for i in c:
        if i.count('.') != h-cnt:
            d.append(i)
    d = list(map(list,d))
    transpose = []
    c = []
    for i in range(len(d[0])):
        tmp = []
        for v in d:
            tmp.append(v[i])
        transpose.append(tmp)
    for i in transpose:
        print(''.join(i))

Solution (Python):
import numpy
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
a = numpy.asarray(a)
a = a[:, numpy.any(a == "
a = a[numpy.any(a == "
for i in range(len(a)):
    print("".join(a[i]))

Solution (Python):
h,w = list(map(int,input().split()))
a = [[i for i in input()] for _ in range(h)]
remove = []
for r in range(h):
  flag = True
  for c in range(w):
    if a[r][c] == "
      flag = False
      break
  if flag:
    remove.append(r)
for i in range(len(remove)):
  a.pop(remove[i])
  remove = [j-1 for j in remove]
remove = []
for c in range(w):
  flag = True
  for r in range(len(a)):
    if a[r][c] == "
      flag = False
      break
  if flag:
    remove.append(c)
for c in range(len(remove)):
  for r in range(len(a)):
    a[r].pop(remove[c])
  remove = [i-1 for i in remove]
  
for r in range(len(a)):
  print("".join(a[r]))

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 = []
tmp = []
ttt = []
ans = []
annn = []
for i in range(H):
    aa = input()
    aa = list(aa)
    a.append(aa)
for i in range(H):
    for j in range(W):
        if '
            tmp.append(a[i])
            break
H = len(tmp)
for i in range(W):
    t = []
    for j in range(H):
        t.append(tmp[j][i])
    ttt.append(t)
for i in range(W):
    for j in range(H):
        if '
            ans.append(ttt[i])
            break
W = len(ans)
for i in range(H):
    t = []
    for j in range(W):
        t.append(ans[j][i])
    annn.append(t)
for i in range(H):
    print(''.join(annn[i]))

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

for i in range(H):
	flg=True
	for j in range(W):
		if aHW[i][j]=='
			flg=False
			break
	if flg:
		ignoreH.append(i)

for i in range(W):
	flg=True
	for j in range(H):
		if aHW[j][i]=='
			flg=False
			break
	if flg:
		ignoreW.append(i)


for i in range(H):
	if i in ignoreH:
		continue
	for j in range(W):
		if j in ignoreW:
			continue
		print(aHW[i][j],end="")
	print()

Solution (Python):
h,w = map(int,input().split())
sl = [input() for _ in [0]*h]
l = []
for i in range(len(sl)):
  if sl[i].count('
    l.append(i)
sl = [sl[i] for i in l]
l = []
for j in range(len(sl[0])):
  flag = False
  for i in range(len(sl)):
    if sl[i][j] == '
      flag = True
  if flag == True:
    l.append(j)
for s in sl:
  s = [s[j] for j in l]
  print(''.join(s))

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

b = []
for i in range(w):
    b.append([])
    for j in range(len(a)):
            b[i].append(a[j][i])

c = []
for i in range(len(b)):
    if b[i].count("
        c.append(b[i])

ans = []
for i in range(len(c[0])):
    ans.append([])
    for j in range(len(c)):
        ans[i].append(c[j][i])

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

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

def main():
	h, w = map(int, input().strip().split())
	a = [[] for _ in range(h)]
	for i in range(h):
		a[i] = list(input().strip())
	for i in range(h):
		flag = True
		for j in range(w):
			if a[i][j] == '
				flag = False
				break
		if flag:
			a[i] = [-1] * w
	for j in range(w):
		flag = True
		for i in range(h):
			if a[i][j] == '
				flag = False
				break
		if flag:
			for i in range(h):
				a[i][j] = -1
	
	for i in range(h):
		for j in range(w):
			if a[i][j] != -1:
				print("{}".format(a[i][j]), end="")
		print("")
if __name__ == '__main__':
	main()

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

yoko_list=[]
tate_list=[]
for i in range(H):
    for j in range(W):
        if hw[i][j]=="
            break
        elif j==W-1:
            yoko_list.append(i)

for i in range(W):
    for j in range(H):
        if hw[j][i]=="
            break
        elif j==H-1:
            tate_list.append(i)

for i in range(H):
    if not i in yoko_list:
        p=0
        for j in range(W):
            if not j in tate_list:
                p+=1
                if p==W-len(tate_list):
                    print(hw[i][j])
                else:
                    print(hw[i][j],end="")