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())
HW_list = [list(input()) for i in range(H)]
import copy

tmp = copy.deepcopy(HW_list)
h_index = 0
for i, HW in enumerate(HW_list):
    is_all_shiro = True
    for hw in HW:
        if hw == '
            is_all_shiro = False
            h_index += 1
            break
    if is_all_shiro:
        tmp.pop(h_index)
w_index = 0
ans = copy.deepcopy(tmp)
for w in range(W):
    is_all_shiro = True
    for t in tmp:
        if t[w] == '
            is_all_shiro = False
            w_index += 1
            break
    if is_all_shiro:
        for a in ans:
            a.pop(w_index)
for A in ans:
    print(''.join(A))

Solution (Python):








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

y = [False] * h
x = [False] * w

for i in range(h):
    for j in range(w):
        if a[i][j] == "
            y[i] = True
            x[j] = True

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

Solution (Python):
h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]
s = [set(), set()]
for i in range(h):
    f = True
    for j in range(w):
        f &= (a[i][j] == ".")
    if f:
        s[0].add(i)

for i in range(w):
    f = True
    for j in range(h):
        f &= (a[j][i] == ".")
    if f:
        s[1].add(i)

for i in range(h):
    if i in s[0]:
        continue
    for j in range(w):
        if j in s[1]:
            continue
        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 = [[0]*w]*h
for i in range(h):
    a[i] = input()

c, l = [], []
for i in range(h):
    flag = True
    for j in range(w):
        if a[i][j] != '.':
            flag = False
            break
    if not flag:
        l.append(i)

for i in range(w):
    flag = True
    for j in range(h):
        if a[j][i] != '.':
            flag = False
            break
    if not flag:
        c.append(i)

for i in range(len(l)):
    s = ''
    for j in range(len(c)):
        s += a[l[i]][c[j]]
    print(s)

Solution (Python):

H,W=map(int,input().split())
a=[list(input()) for _ in range(H)]
h=[]
for i in range(H):
  if a[i]==['.']*W:
    h.append(i)

w=[]
for i in range(W):
  flag=0
  for j in range(H):
    if a[j][i]=='
      flag=1
      break
  if flag==0:
    w.append(i)
  
ans=[]
for i in range(H):
  if i not in h:
    r=[]
    for j in range(W):
      if j not in w:
        r.append(a[i][j])
    ans.append(r)

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

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

w=[]
for i in range(W):
  flag=0
  for j in range(H):
    if a[j][i]=='
      flag=1
      break
  if flag==0:
    w.append(i)
  
ans=[]
for i in range(H):
  if i not in h:
    r=[]
    for j in range(W):
      if j not in w:
        r.append(a[i][j])
    ans.append(r)

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

Solution (Python):
def resolve():
    H, W = map(int, input().split())
    A = []
    count = 0
    ans = []
    for _ in range(H):
        a = input()
        flag = 0
        for __ in range(W):
            if a[__] == "
                flag = 1
        if flag == 1:
            A.append(a)
            count += 1
    for i in range(W):
        flag = 0
        for j in range(count):
            if A[j][i] == "
                flag = 1
        if flag == 0:
            ans.append(i)
    for p in range(count):
        anan = ""
        for q in range(W):
            if q not in ans:
                anan += A[p][q]
        print(anan)
resolve()

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

B = [i for i in A if '

C = [i for i in zip(*B) if '

for i in zip(*C):
    print(''.join(i))

Solution (Python):
h, w = list(map(int, input().split()))
maze = []
for i in range(h):
    maze.append(input())
h_li = []
for i in range(h):
    exclude = True
    for j in range(w):
        if maze[i][j] == '
            exclude = False
    if not exclude:
        h_li.append(i)

w_li = []
for i in range(w):
    exclude = True
    for j in range(h):
        if maze[j][i] == '
            exclude = False
    if not exclude:
        w_li.append(i)

for i in h_li:
    ans = ''
    for j in w_li:
        ans += maze[i][j]
    print(ans)

Solution (Python):
H, W = list(map(lambda x: int(x), input().split(" ")))
A = []
ans = []
whiterows = []
whitecols = []

for i in range(H):
  A.append(list(input()))
  if A[i].count("
    whiterows.append(i)

tA = [list(a) for a in zip(*A)]
for j in range(W):
  if tA[j].count("
    whitecols.append(j)

rows = list(filter(lambda r: r not in whiterows, list(range(H))))
cols = list(filter(lambda c: c not in whitecols, list(range(W))))

for k in rows:
  ans.append("".join([A[k][l] for l in cols]))

print("\n".join(ans))

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


for i in range(h):
    tmp = input()
    flag = 0
    for j in range(len(tmp)):
        if tmp[j] == '
            flag = 1
            break
    if flag == 0:
        continue
    else:
        c.append(tmp)

tate = []

for i in range(len(c[0])):
    flag = 0
    for j in range(len(c)):
        if c[j][i] == '
            flag = 1
            break
    if flag == 0:
        tate.append(i)

for i in range(len(c)):
    c[i] = list(c[i])
    for j in range(len(tate)):
        c[i].pop(tate[j]-j)
    c[i] = ''.join(c[i])
    print(c[i])

Solution (Python):
import numpy as np

h,w = map(int,input().split())
x = [[0 if s=="." else 1 for s in list(input())] for _ in range(h)]

for i in reversed(range(h)):
    if sum(x[i])==0:
        x.pop(i)
x = np.array(x).T.tolist()
for i in reversed(range(len(x))):
    if sum(x[i])==0:
        x.pop(i)
x = np.array(x).T.tolist()
h = range(len(x))
x = [["
for i in h:
    print ("".join(x[i]))

Solution (Python):
h,w=(int(i) for i in input().strip().split(" "))
ar=[]
s=[]
for j in range(h):
    k=[i for i in input().strip()]
    if k==["."]*w:
        pass
    else:
        ar.append(k)

fin=[]
for j in range(w):
    t=[]
    for i in range(len(ar)):
        t.append(ar[i][j])
    if t==["."]*len(t):
        pass
    else:
        fin.append(t)


for j in range(len(fin[0])):
    for i in range(len(fin)):
        print(fin[i][j],end="")
    print()

Solution (Python):
import sys
H,W=map(int,input().split())
a=list(sys.stdin)
rs,cs=[1]*H,[1]*W
for i in range(H):
    for j in range(W):
        if a[i][j]=='
            rs[i]=cs[j]=0
ans=''
for i in range(H):
    if rs[i]:
        continue
    r=''
    for j in range(W):
        if cs[j]:
            continue
        r+=a[i][j]
    ans+=r+'\n'
print(ans)

Solution (Python):
import sys
H,W=map(int,input().split())
a=list(sys.stdin)

q,w=[1]*H,[1]*W
for i in range(H):
    for j in range(W):
        if a[i][j]=='
            q[i]=w[j]=0

ans=''
for i in range(H):
    if q[i]:
        continue
    row=''
    for j in range(W):
        if w[j]:
            continue
        row+=a[i][j]
    ans+=row+'\n'
    

print(ans)

Solution (Python):


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

for i in range(len(A)):
    if ''.join(A[i]) != '.'*len(A[i]):
        B.append(A[i])


C = list(zip(*B))
R = []
for i in range(len(C)):
    if ''.join(C[i]) != '.'*len(C[i]):
        R.append(C[i])

R = list(zip(*R))

for r in R:
    print(''.join(r))

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

    c_h = []
    c_w = []

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

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

    new_a = []

    if len(c_h) == 0:
        if not len(c_w) == 0:

            for i in range(h):
                temp = []
                for j in c_w:
                    temp.append(a[i][j])
                new_a.append(temp)

    elif len(c_w) == 0:
        if not lne(c_h) == 0:

            for i in range(w):
                temp = []
                for j in c_h:
                    temp.append(a[j][i])
                new_a.append(temp)

    elif not(len(c_h) == 0 or len(c_w) == 0):
        for i in c_h:
                temp = []
                for j in c_w:
                    temp.append(a[i][j])
                new_a.append(temp)
    
    else:
        pritn()
        return 0


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

if __name__ == '__main__':
    main()

Solution (Python):
h, w = map(int, input().split())
a = [list(map(str, list(input()))) for i in range(h)]
l1 = ["." for i in range(w)]
l2 = ["." for i in range(h)]
for i in range(h):
  if "
    l2[i] = "
for i in range(w):
  if "
    l1[i] = "
for i in range(h):
  l = []
  for j in range(w):
    if l1[j] == "
      l.append(a[i][j])
  if len(l) != 0:
    print("".join(l))

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())
a1=[[*input()] for _ in range(h)];a2=[i for i,j in enumerate(zip(*a1)) if j.count('.')==h]
[print(*[k for l,k in enumerate(j) if l not in a2],sep='') for j in [i for i in a1 if i.count('.')<w]]

Solution (Python):
H, W = map(int, input().split())
field = []
for _ in range(H):
    tmp = input()
    if tmp.count('
        continue
    else:
        field.append(tmp)
ans_field = [""] * len(field)
for column in range(W):
    del_flag = True
    for row in range(len(field)):
        if field[row][column] == '
            del_flag = False
            break
    if not del_flag:
        for row in range(len(field)):
            ans_field[row] += field[row][column]
for val in ans_field:
    print(val)

Solution (Python):
H, W = map(int, input().split())
field = []
for _ in range(H):
    tmp = input()
    if tmp.count('
        continue
    else:
        field.append(tmp)
ans_field = ["."] * len(field)
for column in range(W):
    del_flag = True
    for row in range(len(field)):
        if field[row][column] == '
            del_flag = False
            break
    if not del_flag:
        for row in range(len(field)):
            ans_field[row] += field[row][column]
for val in ans_field:
    print(val[1:])

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

for i in range(h):
    g.append(list(map(lambda x: 0 if x == '.' else 1, list(input()))))

changed = True
while changed:
    changed = False
    for row in g:
        if sum(row) == 0:
            g.remove(row)
            changed = True

    t = list(zip(*g))
    for column in t:
        if sum(column) == 0:
            t.remove(column)
            changed = True

    g = list(zip(*t))

result = ["".join(list(map(lambda x: "

for row in result:
    print(row)

Solution (Python):
h,w=map(int,input().split())
a=[list(input()) for i in range(h)]
a2=[k for k in a if k!=["." for j in range(w)]]
h=len(a2)
count=[True for j in range(w)]
for j in range(w):
    res=True
    for i in range(h):
        if a2[i][j]=="
            res=False
            break
    if res:
        count[j]=False
a3=[[a2[i][j] for j in range(w) if count[j]] for i in range(h)]
for i in range(h):
    print("".join(a3[i]))

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

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

Solution (Python):
h,w=map(int,input().split())
l=[[] for i in range(h)]
g=[]
r=[]
ans=[[] for i in range(h)]
for i in range(h):
    l[i]=list(input())
for i in range(h):
    if not all(l[i][j]=="." for j in range(w)):
        g.append(i)

for x in range(w):
    if not all(l[j][x]=="." for j in range(h)):
        
        r.append(x)
for i in g:
    for j in r:
        ans[i].append(l[i][j])
for i in g:
    print("".join(ans[i]))

Solution (Python):
H,W = map(int,input().split())
M = [""]*H
r = [False]*H
c = [False]*W

for i in range(H):
  M[i]=input()

for i in range(H):
  for j in range(W):
    if M[i][j]=="
      r[i]=True
      c[j]=True
      
for i in range(H):
  if r[i]:
    for j in range(W):
      if c[j]:
        print(M[i][j],end="")
    print()

Solution (Python):
H,W=map(int,input().split())
D=[]
c=[0]*W
n=[]
for i in range(H):
  a=input()
  d=0
  for j in range(W):
    if a[j]==".":
      c[j]+=1
      d+=1
  if d!=W:
    D.append(a)
for x in range(W):
  if c[x]==H:
    n.append(x)
for y in range(len(D)):
  for z in range(W):
    if z not in n:
      print(D[y][z],end="")
  print("")

Solution (Python):
s = input().split()

h = int(s[0])
w = int(s[1])

line = []
row = []

a = [''] * h

for i in range(h):
    a[i] = input()

for i in range(h):
    line.append(False)
for i in range(w):
    row.append(False)

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

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

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

vrows = {r: False for r in range(h)}
vcols = {c: False for c in range(w)}

for r in range(h):
    for c in range(w):
        if a[r][c] == '
            vrows[r] = True
            vcols[c] = True

for r in range(h):
    if vrows[r]:
        row = ''
        for c in range(w):
            if vcols[c]:
                row += a[r][c]
        print(row)

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

ahw = []
for i in range(h):
  aw = [a for a in input()]
  ahw.append(aw)

row = [False] * h
column = [False] * w
for i in range(h):
  for j in range(w):
    if ahw[i][j] == "
      row[i] = True
      column[j] = True

for i in range(h):
  if row[i] :
    for j in range(w):
      if column[j]:
        print(ahw[i][j],end = "")
    print()

Solution (Python):
import numpy as np

H,W=map(int,input().split())
a=[list(map(int, list(input().replace('

a = np.array(a)

dellist=[]
for i in range(a.shape[0]):
  if a[i,:].sum()==0:
    dellist.append(i)
a = np.delete(a,dellist,0)
    
dellist=[]
for j in range(a.shape[1]):
  if a[:, j].sum()==0:
    dellist.append(j)
a = np.delete(a,dellist,1)

ans=[]
for i in range(a.shape[0]):
  tmp=''
  for j in range(a.shape[1]):
    if a[i][j]==1:
      tmp += '
    else:
      tmp += '.'
  ans.append(tmp)
  
for i in range(len(ans)):
  print(ans[i])

Solution (Python):
sus,fef = map(int,input().split())
r,c = [0]*sus,[0]*fef; 
duk,l,m = [],[],[]
for x in range(sus):
  cuc = input(); duk.append([c for c in cuc])
  r[x] = cuc.count('
  for j in range(fef):
    c[j] += 1 if cuc[j] == '
for rt in range(sus):
  if not r[rt]: l.append(rt)
for gt in range(fef):
  if not c[gt]: m.append(gt)
for x in range(sus):
  if x in l: continue
  cucky = ''
  for y in range(fef):
    cucky += duk[x][y] if y not in m else ''
  print(cucky)

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

H = len(A)
A2 = []
for i in range(W):
    a = ''
    for j in range(H):
        a += A[j][i]
    if set(a) != set('.'):
        A2.append(a)

H = len(A2)
W = len(A2[0])
A = []
for i in range(W):
    a = ''
    for j in range(H):
        a += A2[j][i]
    A.append(a)

for a in A:
    print(a)

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

Solution (Python):


import sys
input = sys.stdin.readline  
H,W = map(int, input().split())
a =[]
for h in range(H):
    *aa, =input().strip()
    a.append(aa)

x =["."]*W
del_h =[]
for h in range(H):
    if a[h] ==x:
        del_h.append(h)

y =["."]*H
del_w =[]
for w in range(W):
    d =[]
    for h in range(H):
        if a[h][w] ==".":
            d.append(".")
    if d ==y:
        del_w.append(w)

for i in range(H):
    if i in del_h:
        continue
    for j in range(W):
        if j in del_w:
            continue
        print(a[i][j],end="")
    print()

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

c = [i for i in range(W)]
for i in range(len(b)):
    for j in range(W):
        if b[i][j] == "
            if j in c:
                c.remove(j)
c.sort()
cnt = 0
for i in range(len(c)):
    c[i] -= cnt
    cnt += 1
for i in c:
    for j in range(len(b)):
        b[j] = b[j][:i]+b[j][i+1:]
for i in range(len(b)):
    print(b[i])

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

for i in range(h):
    a[i] = input()
    
row = [False] * h
cal = [False] * w

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

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

A=[]
for h in range(H):
    a = input()
    if '
        A.append(list(a))

A=np.array(A).T
A_=[]
for w in range(W):
    a=A[w]
    if '
        A_.append(a)
        
A_=np.array(A_).T
for a in A_:
    print(''.join(a))

Solution (Python):
import numpy as np
h,w = map(int, input().split())
a = []
for i in range(h):
    b = list(input())
    if b.count('.') == w:
        continue
    else:
        a.append(b)
c = np.array(a)
d = c.T
e = d.tolist()
f = []
for i in range(d.shape[0]):
    if e[i].count('.') == d.shape[1]:
        f.append(i)
f.sort(reverse = True)
for i in f:
    d = np.delete(d, i, 0)
ans = d.T.tolist()
for i in range(len(ans)):
    print(''.join(ans[i]))

Solution (Python):

import numpy as np

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

a = np.array([list(input()) for i in range(h)])

need_h = []
need_w = []
for i in range(h):
    tmp = a[i, :].tolist()
    if set(tmp) != set(["."]):
        need_h.append(i)


for i in range(w):
    tmp = a[:, i].tolist()
    if set(tmp) != set(["."]):
        need_w.append(i)




ans = np.take(np.take(a, need_h, axis=0), need_w, axis=1)

for i in ans:
    print("".join(i.tolist()))

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

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

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

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

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

count = 0
index = 0
while count < H:
    line = board[index]
    isWhite = True
    for i in range(len(line)):
        if line[i] == '
            isWhite = False
    if isWhite:
        board.pop(index)
    else:
        index += 1
    count += 1

count = 0
index = 0
while count < W:
    isWhite = True
    for i in range(len(board)):
        if board[i][index] == '
            isWhite = False
    if isWhite:
        for j in range(len(board)):
            board[j].pop(index)
    else:
        index += 1
    count += 1

for i in range(len(board)):
    line = board[i]
    lineString = ''
    for j in range(len(line)):
        lineString += line[j]
    print(lineString)

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    h, w = map(int, readline().split())
    grid = []
    hd = 0
    for row in range(h):
        s = input()
        if all([char == "." for char in s]):
            hd += 1
        else:
            grid.append(s)

    rem = []
    for col in range(w):
        for row in range(h - hd):
            if grid[row][col] == "
                break
        else:
            rem.append(col)

    for row in range(h-hd):
        disp = ""
        for col in range(w):
            if col in rem:
                continue
            disp += grid[row][col]
        print(disp)


if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np
H,W = (int(X) for X in input().split())
A = np.zeros((H,W),dtype=bool)
for TH in range(0,H):
    A[TH,:] = np.array([True if X=='.' else False for X in input()])
    Row = [TH for TH in range(0,H) if np.all(A[TH,:])==True]
for TW in range(0,W):
    Column = [TW for TW in range(0,W) if np.all(A[:,TW])==True]

A = np.delete(np.delete(A,Row,0),Column,1)
for THD in range(0,H-len(Row)):
    Disp = ['.' if X==True else '
    print(''.join(Disp))

Solution (Python):
H,W = [int(i) for i in input().split()]
A = [list(input()) for i in range(H)]
i = 0
while i < len(A):
    if A[i].count(".") == len(A[0]):
        del A[i]
    else:
        i += 1
i = 0
while i < len(A[0]):
    if [j[i] for j in A].count(".") == len(A):
        for j in range(len(A)):
            del A[j][i]
    else:
        i += 1
print("\n".join("".join(i) for i in A))

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

A = list(filter(lambda a: any(x=='


A = list(filter(lambda a: any(x=='



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

Solution (Python):























































































def calculation(lines):
    N, W = list(map(int, lines[0].split()))
    masus = list()
    for i in range(N):
        line = lines[i+1]
        if line != '.'*W:
            masus.append(line)
    for w in range(W):
        flag = True
        for masu in masus:
            if masu[w] == '
                flag = False
        if flag:
            for i in range(len(masus)):
                masus[i] = masus[i][:w] + ' ' + masus[i][w+1:]
    for i in range(len(masus)):
        masus[i] = masus[i].replace(' ', '')
    return masus



def get_input_lines():
    line = input()
    H, W = list(map(int, line.split()))
    lines = list()
    lines.append(line)
    for _ in range(H):
        lines.append(input())
    return lines



def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['4 4', '
        lines_export = ['
    if pattern == 2:
        lines_input = ['3 3', '
        lines_export = ['
    if pattern == 3:
        lines_input = ['4 5', '.....', '.....', '..
        lines_export = ['
    if pattern == 4:
        lines_input = ['7 6', '......', '....
        lines_export = ['..
    return lines_input, lines_export



def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode



def main():
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines()
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    
    
    
    
    
    
    
    



if __name__ == '__main__':
    main()

Solution (Python):
if __name__ == '__main__':
	w,h = map(int,input().split())
	
	A = []
	for _ in range(w):
		cmd = input()
		if cmd.count(".") != len(cmd):
			A.append(cmd)

	B = []
	for i in range(h):
		st = ""
		for a in A:
			st += a[i]
		if st.count(".") != len(st):
			B.append(st)

	
	C = []
	w = len(B[0])
	for j in range(w):
		st = ""
		for b in B:
			st += b[j]
		C.append(st)

	for c in C:
		print(c)

Solution (Python):
h,w=map(int,input().split())
g=[input() for _ in range(h)]
a=['' for _ in range(h)]
for y in range(w):
  if any(s[y]=='
    for x in range(h):
      a[x]+=g[x][y]
for s in a:
  if s.count('

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

for _ in range(w):
    for i, j in enumerate(a):
        if set(j) == set("."):
            a.pop(i)
    a_t = [list(x) for x in zip(*a)]
    for i, j in enumerate(a_t):
        if set(j) == set("."):
            a_t.pop(i)
    a = [list(x) for x in zip(*a_t)]

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

Solution (Python):
MM = input().split()
A = int(MM[0])
B = int(MM[1])
list1 =[]
for i in range(A):
  aa = input()
  if '.'*B == aa:
    pass
  else:
    list1.append(list(aa))


for i in range(B):
  count = 0
  for j in range(len(list1)):
    if list1[j][i] == '
      count +=1
  if count == 0:
    for j in range(len(list1)):
     
      list1[j][i] = 'a'

for i in list1:
  if 'a' in i:
    i.remove('a')

for i in list1:
  for j in i:
    if j != 'a':
      print(j,end='')
  print()

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

w_row = ['.' for i in range(w)]
del_row_list = []
del_col_list = []

for i in range(h):
    if field[i] == w_row:
        del_row_list.append(i)

for j in range(w):
    count = 0
    for i in range(h):
        if field[i][j] == '.':
            count += 1
    if count == h:
        del_col_list.append(j)

for i in range(h):
    if i in del_row_list:
        continue
    for j in range(w):
        if j in del_col_list:
            continue
        print(field[i][j], end='')
    print('')

Solution (Python):
import copy
H,W=map(int,input().split())
List = []
for i in range (H):
  List.append(list(input()))
flag = False
NewList = []

for i in range(H):
  for j in range(W):
    if List[i][j]== "
      flag = True
  if flag:
    NewList.append(List[i])
  flag = False
flag1 = [True]*W

for i in range(W):
  for j in range(len(NewList)):
    if NewList[j][i]== "
      flag1[i] = False
      
for j in range(len(NewList)):
  for i in range(W-1,-1,-1):
    if flag1[i]:
      NewList[j].pop(i)    
  
resList=[""]*H
for i in range(len(NewList)):
  for j in range(len(NewList[i])):
    resList[i] += NewList[i][j]
for element in resList:
  print(element)

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

next_data = []

for d in data:
    if "
        next_data.append( d )

next_next_data = []
origin_v_data = []

for i in range( len(next_data[0]) ):
    
    v_data = []
    for j in range( len(next_data) ):
        v_data.append( next_data[j][i] )

    
    if "
        origin_v_data.append( v_data )

ans_data = []
for i in range( len(origin_v_data[0]) ):
    join_data = []
    for j in range( len(origin_v_data) ):
        join_data.append( origin_v_data[j][i] )
    ans_data.append( join_data )


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

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


row = []
column = []
for i in range(h):
    if not masu[i] == ['.'] * w:
        row.append(i)

column = []
for i in range(w):
    flg = 0
    for j in range(h):
        if masu[j][i] == '
            flg = 1
    if flg == 1:
        column.append(i)

for i in row:
    for j in column:
        print(masu[i][j],end='')
    print()

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


row = []
column = []
for i in range(h):
    if not masu[i] == ['.'] * w:
        row.append(i)

column = []
for i in range(w):
    flg = 0
    for j in range(h):
        if masu[j][i] == '
            flg = 1
    if flg == 1:
        column.append(i)

for i in row:
    l = masu[i]
    for j in column:
        print(masu[i][j],end='')
    print()

Solution (Python):
h, w = map(int, input().split())
a = []
for _ in range(h):
    x = input()
    if "
        a.append(x)
    else:
        h -= 1
for i in range(w - 1, -1, -1):
    for j in range(h):
        if a[j][i] == "
            break
    else:
        for k in range(h):
            a[k] = a[k][:i] + a[k][i + 1 :]
print(*a, sep="\n")

Solution (Python):
h,w=map(int,input().split())
a=[input() for _ in range(h)]
sh=set()
sw=set()
for i in range(h):
    ok=True
    for j in range(w):
        if a[i][j]=="
            ok=False
    if ok:
        sh.add(i)
for j in range(w):
    ok=True
    for i in range(h):
        if a[i][j]=="
            ok=False
    if ok:
        sw.add(j)


ans=[]
for i in range(h):
    l=""
    if i in sh:
        continue
    for j in range(w):
        if j in sw:
            continue
        l+=a[i][j]
    ans.append(l)
for c in ans:
    print(c)

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

dlist = []
nuse = [0]*w

for i in range(h):
    if not "
        dlist.append(i)
    for j in range(w):
        if field[i][j] == "
            nuse[j] += 1

nuse = [True if w > 0 else False for w in nuse]
for i in range(h):
    if i in dlist:
        continue
    s = list(itertools.compress(field[i], nuse))
    print("".join(s))

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