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

..#
#..
.#.
.#.
#.#



Sample input:
4 4
##.#
....
##.#
.#.#


Sample output:
###
###
.##

Submission status: Runtime Error

Solution code:
h, w = map(int, input().split())
a = [input() for _ in range(h)]
memo_yoko = [False]*w
memo_tate = [False]*h
for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            memo_yoko[i] = True
            memo_tate[j] = True
for i in range(h):
    if memo_yoko[i]:
        for j in range(w):
            if memo_tate[j]:
                print(a[i][j], end="")
        print()

Submission status: Runtime Error

Solution code:
import numpy as np

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

ans = []

judge_h = []

for i in range(H):
    tmp = list(map(str, input().rstrip()))
    ans.append(tmp)
    if tmp.count("#")==0:
        judge_h.append(False)
    else:
        judge_h.append(True)

ans = np.array(ans)

judge_w = []

for i in range(W):
    if np.where(ans[:, i]=="#")[0].shape[0]==0:
        judge_w.append(False)
    else:
        judge_w.append(True)

ans = ans[judge_h, :]
ans = ans[:, judge_w]
ans = [list(i) for i in ans]

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

Submission status: Runtime Error

Solution code:
import numpy as np

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

ans = []

judge_h = []

for i in range(H):
    tmp = list(map(str, input().rstrip()))
    ans.append(tmp)
    if tmp.count("#")==0:
        judge_h.append(False)
    else:
        judge_h.append(True)

ans = np.array(ans)

judge_w = []

for i in range(W):
    if np.where(ans[:, i]=="#")[0].shape[0]==0:
        judge_w.append(False)
    else:
        judge_w.append(True)

ans = ans[judge_h, :]
ans = ans[:, judge_w]

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

Submission status: Runtime Error

Solution code:
import numpy as np

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

ans = []

for i in range(H):
    tmp = list(map(str, input().rstrip()))
    if tmp.count("#")==0:
        continue
    else:
        ans.append(tmp)

ans = np.array(ans)

judge = []

for i in range(W):
    if np.where(ans[:, i]=="#")[0].shape[0]==0:
        judge.append(False)
    else:
        judge.append(True)

ans = ans[:, judge]

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

Submission status: Runtime Error

Solution code:
# coding: utf-8

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

for i in range(h):
    l = list(input())
    if list(set(l)) == ['.']:
        h -= 1
    else:
        A.append(l)
#for a in A:
    #print(a)
Ans = []
for i in range(w):
    cnt = 0
    for j in range(h):
        if A[j][i] == '.':
            cnt += 1
    if cnt == h:
        Ans.append(i)

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

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

Submission status: Runtime Error

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

res=[]
for i in range(h):
    if "#" not in a[i]:
      res.append(i)
for i in res:
  a.pop(i)
res=[]
h=len(a)
for i in range(w):
    for j in range(len(a)):
      if a[j][i]=="#":
        break
    else:
      res.append(j)
for i in res:
  for j in range(len(a)):
    a[j]=a[j][:i]+a[j][i+1:]
for i in a:
  print(*i)

Submission status: Runtime Error

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

#タテのチェック
for i in range(w):
	tmp=0
	for j in range(h):
		if a[j][i]=="#":
			tmp=1
	if tmp==0:
		for j in range(h):
			a[j][i]="0"

#ヨコのチェック
for i in range(h):
	if not "#" in a[i][:]:
		a[i][:]=[0]*w

for i in range(h):
	tmpl=[]
	for j in range(w):
		if not a[i][j]=="0":
			tmpl.append(a[i][j])
	if "#" in tmpl or "." in tmpl:
		print("".join(tmpl))		#listを詰めて表示

Submission status: Runtime Error

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

#タテのチェック
for i in range(w):
	tmp=0
	for j in range(h):
		if a[j][i]=="#":
			tmp=1
	if tmp==0:
		for j in range(h):
			a[j][i]="0"

#ヨコのチェック
for i in range(h):
	if not "#" in a[i][:]:
		a[i][:]=[0]*w

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

Submission status: Runtime Error

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

#タテのチェック
for i in range(w):
	tmp=0
	for j in range(h):
		if a[j][i]=="#":
			tmp=1
	if tmp==0:
		for j in range(h):
			a[j][i]="0"

#ヨコのチェック
for i in range(h):
	if not "#" in a[i][:]:
		a[i][:]=[0]*w

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

Submission status: Runtime Error

Solution code:
h,w = map(int,input().split())
maze = []
for _ in range(h):
  s = input()
  if s != '.'*w:
    maze.append(s)
h = len(maze)
skip = []
for j in range(w):
  for i in raneg(h):
    if maze[i][j] == '#':
      break
  else:
    skip.append(j)

for i in range(h):
  for j in range(w):
    if j not in skip:
      print(maze[i][j],end= '')
  print()

Submission status: Runtime Error

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

f = []

for i in range(h):
    f.append(list(input()))
    
a = []
    
for i in range(len(f)):
    if f[i] == ["."]*len(f[i]):
        a.append(i)
        
for i in a:
    del f[i]
    for s in range(len(a)):
        a[s] -= 1
        
f2 = []

for i in range(w):
    s = []
    
    for k in f:
        s.append(k[i])
        
    f2.append(s)
    
b = []
    
for i in range(len(f2)):
    if f2[i] == ["."]*len(f2[i]):
        b.append(i)
        
for i in b:
    del f2[i]
    for s in range(len(b)):
        b[s] -= 1
        
ff = []

for i in range(len(f2)):
    s = []
    
    for k in f2:
        s.append(k[i])
        
    ff.append(s)
        
for i in ff:
    for s in range(len(i)-1):
        print(i[s],end = "")
    
    print(i[-1])

Submission status: Runtime Error

Solution code:
H, W = map(int, input().split())
field = [[i for i in input()] for j in range(H)]

b_rows = []
for row in range(H):
    if field[row].count(".") != W:
        b_rows.append(row)

b_columns = []
for column in range(W):
    memo = []
    for row in range(H):
        memo.append(field[column][row])
    if memo.count(".") != H:
        b_columns.append(column)

for i in b_rows:
    for j in b_columns:
        print(field[i][j], end="")
    print()

Submission status: Runtime Error

Solution code:
H, W = map(int, input().split())
G = []

for i in range(H):
  line = input()
  if line != '.' * W:
    G.append(line)

H = len(G)
ans = []

for i in range(W):
  flg = False
  tmp = ''
  for j in range(H):
    if G[j][i] == '.':
      flg = False
    else:
      flg = True
    tmp += G[j][i]
  if tmp != '.' * H:
    ans.append(tmp)

for i in range(len(ans[0])):
  tmp = ''
  for j in range(H):
    tmp += ans[j][i]
  print(tmp)

Submission status: Runtime Error

Solution code:
import numpy as np
h,w=map(int,input().split())
a=[list(input()) for i in range(h)]
np_a=np.array(a)
np_at=np_a.T
at=np_at.tolist()

r=[]
c=[]

for i in range(h):
    if a[i].count('#')==0:
        r.append(i)
for i in range(w):
    if at[i].count('#')==0:
        c.append(i)

k=h-len(r)
for i in r:
    del a[i]
for j in c:
    for i in range(k):
        del a[i][j]

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

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
from copy import deepcopy
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

h,w=MI()
data=[list(input().rstrip()) for i in range(h)]
#print(data)
deletes=[]
for i in range(h):
    count=0
    for j in range(w):
        if data[i][j]==".":
            count+=1
    if count==w:
        deletes.append(i)
for j in list(reversed(deletes)):
    del data[j]
#print(data)
h-=len(deletes)
data2=[[0 for i in range(h)] for j in range(w) ]
for i in range(w):
    for j in range(h):
        data2[i][j]=data[j][i]
#print(data2)
deletes2=[]
for i in range(w):
    count=0
    for j in range(h):
        if data2[i][j]==".":
            count+=1
    if count==h:
        deletes2.append(i)
for j in list(reversed(deletes2)):
    del data2[j]
w-=len(deletes2)
#print(data2)
data3=[[0 for i in range(h)] for j in range(w) ]
for i in range(h):
    for j in range(w):
        data3[i][j]=data2[j][i]
#print(data3)
for i in range(h):
    for j in range(w):
        print(data3[i][j],end="")
    print("")

Submission status: Runtime Error

Solution code:
h,w=map(int,input().split())
lis=[]
for i in range(h):
  lis.append(list(input()))
for i in range(0,len(lis)):
  i=len(lis)-i-1
  count=0
  for j in range(0,len(lis[0])):
    if lis[i][j]==".":
      count+=1
  if count==len(lis[0]):
    lis.pop(i)

for i in range(0,len(lis[0])):
  i=len(lis)-i-1
  count=0
  for j in range(0,len(lis)):
    if lis[j][i]==".":
      count+=1
  if count==len(lis):
    for k in range(len(lis)):
      lis[k].pop(i)

for i in range(len(lis[0])):
  moji=""
  for j in range(len(lis)):
    moji+=lis[i][j]
  print(moji)

Submission status: Runtime Error

Solution code:
def oneCol(mat,n):
  ans = ""
  for i in range(len(mat)):
    ans = ans + mat[i][n]
  return ans

def strCut(s,n):
  return s[0:n] + s[n+1:len(s)]

def lowCut(mat):
  for i in range(len(mat)):
    if not "#" in mat[len(mat)-i-1]:
      delete mat[len(mat)-i-1]
  return mat

def colCut(mat):
  for i in range(len(mat[0])):
    if not "#" in oneCol(mat,len(mat[0])-i-1):
      mat2 = []
      for k in range(len(mat)):
        mat2.append(strCut(mat[k],len(mat[0])-i-1))
  return mat
      

H,W=map(int, input().split())
s_list = []
for i in range(H):
  s = input()
  if "#" in s: s_list.append(s)

    
while True:
  lowCut(mat)
  colCut(mat)
  print(mat)

Submission status: Runtime Error

Solution code:
a,b = list(map(int,input().split()))
A = []
list = [["" for i in range(b)] for j in range(a)]
for i in range(a):
    n = input()
    if n.count(".") == b:
       pass 
    else:
        for j in range(b):
            list[i][j] = n[j]
for i in range(b):
    for j in range(a):
        A.append(list[j][i])
    if len(A) == A.count(".")+A.count(""):
        for k in range(a):
            list[k][i] = ""
    A = []
for i in range(a):
    for j in range(b):
        if list[i][j] != "":
            print(list[i][j],end="")
            AAA = 1
    if AAA == 1:
        print()
    AAA = 0

Submission status: Runtime Error

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


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

for i in range(h):
    if set(a[i]) == {"."}:
        delrow.append(i)

for i in range(w):
    if set(a[0:w][i]) == {"."}:
        delcol.append(i)
        
for i in delrow [::-1]: #行を削除
    del a[i]
for i in delcol [::-1]: #列を削除
    for j in range(len(a)):
        del a[j][i]

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

Submission status: Runtime Error

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


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

for i in range(h):
    print(set(a[i]))
    if set(a[i]) == {"."}:
        delrow.append(i)

for i in range(w):
    print(set(a[0:w][i]))
    if set(a[0:w][i]) == {"."}:
        delcol.append(i)
        
for i in delrow [::-1]: #行を削除
    del a[i]
for i in delcol [::-1]: #列を削除
    for j in range(len(a)):
        del a[j][i]

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

Submission status: Runtime Error

Solution code:
num = list(map(int, input().split()))

grid = []
del_i = []
del_n = []

for i in range(num[0]):
  grid.append(list(input()))

  if "#" in grid[i] and "." in grid[i]:
    continue
  else:
    del_i.append(i)

check_1, check_2 = 0, 0

for n in range(num[1]):
  check_1, check_2 = 0, 0
  for i in range(num[0]):
    if grid[i][n] == "#":
      check_1 += 1
      if check_2 > 0:
        break
      if check_1 == num[0]:
        del_n.append(n)
    else:
      check_2 += 1
      if check_1 > 0:
        break
      if check_2 == num[0]:
        del_n.append(n)

for i in range(num[0]):
  if i in del_i:
    continue
  else:
    for n in del_n:
      del grid[i][n]
    print(''.join(grid[i]))

Submission status: Runtime Error

Solution code:
num = list(map(int, input().split()))

grid = []
del_i = []
del_n = []

for i in range(num[0]):
  grid.append(list(input()))

  if "#" in grid[i] and "." in grid[i]:
    continue
  else:
    del_i.append(i)

check_1, check_2 = 0, 0

for n in range(num[1]):
  check_1, check_2 = 0, 0
  for i in range(num[0]):
    if grid[i][n] == "#":
      check_1 += 1
      if check_2 > 0:
        break
      if check_1 == num[0]:
        del_n.append(n)
    else:
      check_2 += 1
      if check_1 > 0:
        break
      if check_2 == num[0]:
        del_n.append(n)

for i in range(num[0]):
  if i in del_i:
    continue
  else:
    for n in del_n:
      del grid[i][n]
      print(''.join(grid[i]))

Submission status: Runtime Error

Solution code:
H,W=map(int, input().split())
masu_list = []
for i in range(H):
  S=str(input())
  if S.count('#') != 0:
    masu_list.append(S)

yet = True
while yet:
  for i in range(len(masu_list[0])):
    if masu_list[i].count('#') == 0:
      masu_list.delete(i,1)

Submission status: Runtime Error

Solution code:
import numpy as np


def yoko(row):
    cnt = sum(row)
    return cnt == len(row)


def main():
    h, w = map(int, input().split(' '))
    a = []

    for i in range(h):
        b = input()
        a += [1 if c == '.' else 0 for c in b]
    a = np.array(a).reshape(h, w)

    while True:
        cnt = 0
        del_list = []
        for i in range(len(a)):
            judge = yoko(a[i])
            if judge:
                del_list.append(i)

        if len(del_list):
            for idx in del_list:
                a = np.delete(a, idx, axis=0)
        else:
            cnt += 1

        a = a.T

        del_list = []
        for i in range(len(a)):
            judge = yoko(a[i])
            if judge:
                del_list.append(i)

        if len(del_list):
            for idx in del_list:
                a = np.delete(a, idx, axis=0)
        else:
            cnt += 1

        a = a.T

        if cnt >= 2:
            break

    for i in range(len(a)):
        r = ''
        for j in a[i]:
            if j == 1:
                r += '.'
            else:
                r += '#'
        print(r)


main()

Submission status: Runtime Error

Solution code:
# AtCoder
H, W = map(int, input().split())
a = [input() for _ in range(H)]
good_x = [False]*H
good_y = [False]*W

for i in range(H):
    for j in range(W):
        if a[i][j] == '#':
            good_x[i] = True
            good_y[i] = True

for i in range(H):
    if good_x[i]:
        for j in range(W):
            if good_y[j]:
                print(a[i][j], end='')
        print()

Submission status: Runtime Error

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

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

i=0
rm=0
for i in range(H):
  if a[i].count('#')==0:
    k=i
    for j in range(H-k-1):
      a[k+j]=a[k+j+1]
    H=H-1
    
for j in range(W):
  flag=1
  for i in range(H):
    #print(i,j,a[i][j])
    if a[i][j]=='#':
      flag=flag*0
  if flag==1:
    for i in range(H):
      a[i][j]='-' 
    W=W-1

for i in range(H) :
  if a[i].count('-')!=0:
    a[i].remove('-')
  
ans=list('' for i in range(W))

N=len(a[0])

for i in range(H):
  for j in range(N):
    ans[i]=ans[i]+a[i][j]
    
for i in range(H):
  print(ans[i])

Submission status: Runtime Error

Solution code:
import numpy as np
import sys
import pandas as pd

N = input() # 入力回数をNとして受け取る
n = N.split(" ")
col = int(n[1])
rows = int(n[0])
s = [input() for i in range(rows)] # 複数行の数値の入力を取得
arr_1d = np.array(s)
arr_2 = []
for el in arr_1d:
    chars = [char for char in el ]
    arr_2.append(chars)

arr_2 = np.array(arr_2)
df = pd.DataFrame(arr_2.reshape(rows,col))
df2 = df.replace(["."], np.nan)
df2=df2.dropna(how='all').dropna(how='all', axis=1)
df2=df2.fillna(".")
# print(df2.values)
for a in df2.values:
    print(''.join(a))

Submission status: Runtime Error

Solution code:
p,q= input().split()
a,b =(int(p), int(q))
a_list = []
count_row = 0
for i in range(a):
    c = input()
    
    if c == '.'*b:
        count_row+=1
    else:
        a_list.append(c)
for i in range(b):
    count_clm = 0
    
    for j in range(a-count):
        if a_list[j][i] == '.':
            count_clm+=1
        else:
            break
    if count_clm == (b-count_clm):
        for j in range(a-count_row):
            a_list[j].pop(i)
            
            
for i in range(a-count_row):
    print(a_list[i])

Submission status: Runtime Error

Solution code:
h,w = map(int,input().split())
l = list(list(input()) for i in range(h))
for i in l:
  if i.count('.') ==w:
    i.clear()
    l.remove([])
t = len(l)
for i in range(w):
  if all (l[q][i]=="." for q in range(t)):
    for q in range(t):
      l[q][i] =""
for z in l:
  z.remove("")
for i in l:
  print("".join(i))

Submission status: Runtime Error

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

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

y = [False]*H
x = [False]*H

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

Submission status: Runtime Error

Solution code:
h,w = map(int,input().split())
l = list(list(input()) for i in range(h))
for i in l:
  if i.count('.') ==w:
    i.clear()
    l.remove([])
t = len(l)
#print(l)
for i in range(w):
  if all (l[q][i]=="." for q in range(t)):
    for q in range(t):
      l[q][i] =""
for z in range(t):
  l[z].remove("")
print(l)

Submission status: Runtime Error

Solution code:
H,W = map(int,input().split())
mas = [list(input()) for i in range(H)]
new_mas = [row for row in mas if "#" in row:]
new_mas2 = [column for column in list(zip(*new_mas)) if "#" in column]
for i in list(zip(*new_mas2)):
    for j in i:
        print(j,end="")
    print()

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    for (int i=0; i<h; i++) {
        cin >> a.at(i);
    }
    vector<bool> row(h, false);
    vector<bool> col(w, false);
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            if (a.at(i).at(j) == '#') {
				row[i] = true;
				col[j] = true;
            }
        }
    }

	for (int i = 0; i < h; i++) {
		if (row[i]) {
			for (int j = 0; j < w; j++) {
				if (col[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}    
}

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
H_W = list(map(int,input().split()))
H = H_W[0]
W = H_W[1]
b = [[0 for i in range(W)] for j in range(H)]
a = [[str(c) for c in l.strip()] for l in sys.stdin]

# .を0に, #を1にした新しい配列bを作る
for i in range(H):
    for j in range(W):
        if a[i][j] == '#':
            b[i][j] = 1

# 列と行ごとにすべて0のものを探す
w = [0] * W
h = [0] * H
for i in range(H):
    for j in range(W):
        h[i] = h[i] + b[i][j]
        w[j] = w[j] + b[i][j]

# 全ての要素が0の列と行を削除する
for i in range(H):
    if h[i] == 0:
        del a[i]
        H = H -1
    if w[i] == 0:
        for j in range(H):
            del a[j][i]
        W = W - 1
# 答え
for i in range(H):
    flag = 0
    for j in range(W):
        if flag == 0:
            ans = a[i][j]
            flag = 1
        else:
            ans = ans + a[i][j]
    print(ans)

Submission status: Runtime Error

Solution code:
h,w=map(int,input().split())
l=[list(input()) for _ in range(w)]
l=[x for x in l if '#' in x]
l=[x for x in zip(*l) if '#' in x]
for i in zip(*l):
	print(''.join(i))

Submission status: Runtime Error

Solution code:
h,w=map(int,input().split())
l=[list(map(input().split())) 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()

Submission status: Runtime Error

Solution code:
h , w = map(int,input().split())
a = [''] * h 
for i in range(n):
    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()

Submission status: Runtime Error

Solution code:
h,w=map(int,input().split())
a=[]
for i in range(h):
  tmp=input()
  if len(tmp)!=tmp.count('.'):
    a.append(tmp)
  else:
    h-=1
    
a=list(zip(*a))
for i in range(w):
  if len(a[i])==a[i].count('.'):
    del a[i]
    w-=1
    i-=1
    
a=list(zip(*a))
for i in range(h):
  print(a[i])

Submission status: Runtime Error

Solution code:
import functools
import numpy as np
H, W = map(int, input().split())
mat = np.array([list(input()) for _ in range(H)])


def get_bool(x, value, axis):
    return np.where(x == value, True, False).all(axis=axis)


custom_get_bool = functools.partial(mat, '.')
mat = mat[:, ~custom_get_bool(0)]
mat = mat[~custom_get_bool(1)]
print('\n'.join([''.join(row) for row in mat]))

Submission status: Runtime Error

Solution code:
import functools
import numpy as np
H, W = map(int, input().split())
mat = np.array([list(input()) for _ in range(H)])


def get_bool(x, value, axis):
    return np.where(x == value, True, False).all(axis=axis)


custom_get_bool = functools.partial((mat, '.'))
mat = mat[:, ~custom_get_bool(0)]
mat = mat[~custom_get_bool(1)]
print('\n'.join([''.join(row) for row in mat]))

Submission status: Runtime Error

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

A = ""

for _ in range(H):
  s = input()
  if len(set(s)) == 1 and s == "." * W:
    H -= 1
  else:
    for i in s:
      A.append(i)

if len(A) == 0:
  print(A)

else:
  M = []

  for i in range(W):
    if A[i] == ".":
      for j in range(i + W,H * W,W):
        if A[j] == "#":
          break
      else:
        M.append(i)

  A = [A[i] for i in range(H * W) if not (i % W) in M]
  W = W - len(M)
  
  S = ""
  
  for i in range(H * W):
    S += A[i]
    if (i + 1) % W == 0:
      print(S)
      S = ""

Submission status: Runtime Error

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

A = []

for _ in range(H):
  s = input()
  if len(set(s)) == 1:
    H -= 1
  else:
    for i in s:
      A.append(i)

M = []

for i in range(W):
  if A[i] == ".":
    for j in range(i + W,H * W,W):
      if A[j] == "#":
        break
    else:
      M.append(i)
      
A = [A[i] for i in range(H * W) if not (i % W) in M]
W = W - len(M)

S = ""

for i in range(H * W):
  S += A[i]
  if (i + 1) % W == 0:
    print(S)
    S = ""

Submission status: Runtime Error

Solution code:
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[i] = True
for i in range(h):
    if row[i]:
        for j in range(w):
            if col[j]:
                print(a[i][j], end = "")
        print()

Submission status: Runtime Error

Solution code:
satooh
H, W = map(int, input().split())
a = [list(input()) for _ in range(H)]
a = [i for i in a if "#" in "".join(i)]
# print("step1", a)
a = list(zip(*a))
# print("step2", a)
a = [j for j in a if "#" in "".join(j)]
# print("step3", a)
a = list(zip(*a))
# print("step4", a)
for n in range(len(a)):
	print("".join(a[n]))

Submission status: Runtime Error

Solution code:
salmo
h, w = map(int, input().split())
a = [list(input()) for i in range(h)]
for i in range(h):
    if set(a[h-i-1]) == {'.'}:
        del(a[h-i-1])
for i in range(w):
    if set([j[w-i-1] for j in a]) == {"."}:
        for j in a:
            del(j[w-i-1])
for i in a:
    print(''.join(i))

Submission status: Runtime Error

Solution code:
a

Submission status: Runtime Error

Solution code:
def get_input():
      w = input()
      h = input()
      a = []
      for i in range(int(w)):
            sub_a = []
            for j in range(int(h)):
                  sub_a.append(input())
            a.append(sub_a)

      return a

def transpose(mat):
      mat2 =[[row[i] for row in mat] for i in range(len(mat[0]))]
      return mat2

def get_output(mat):
      # done_flag = False
      point_count = 0
      i = 0
      while i<len(mat):
            j = 0
            while j<len(mat[0]):
                  if(mat[i][j] == '.'):
                        point_count += 1
                  j+=1            
            
            if point_count == len(mat[0]):
                  del mat[i]
                  i = 0
                  point_count = 0
                  continue
            i+=1
            point_count = 0
            # print(mat)

      mat = transpose(mat)

      point_count = 0
      i = 0
      while i<len(mat):
            j = 0
            while j<len(mat[0]):
                  if(mat[i][j] == '.'):
                        point_count += 1
                  j+=1            
            
            if point_count == len(mat[0]):
                  del mat[i]
                  i = 0
                  point_count = 0
                  continue
            i+=1
            point_count = 0
            # print(mat)

      return transpose(mat)

def print_out(mat):
      for i in range(len(mat)):
            for j in range(len(mat[0])):
                  if(j==(len(mat[0])-1)):
                        print (mat[i][j])
                  else:
                        print (mat[i][j], end='')

if __name__ == '__main__':
    mat = get_input()
    mat2 = get_output(mat)

    print_out(mat2)

# del a[1]

Submission status: Runtime Error

Solution code:
def get_input():
      w = input()
      h = input()
      a = []
      for i in range(w):
            sub_a = []
            for j in range(h):
                  sub_a.append(raw_input())
            a.append(sub_a)
      return a

def transpose(mat):
      mat2 =[[row[i] for row in mat] for i in range(len(mat[0]))]
      return mat2

def get_output(mat):
      # done_flag = False
      point_count = 0
      i = 0
      while i<len(mat):
            j = 0
            while j<len(mat[0]):
                  if(mat[i][j] == '.'):
                        point_count += 1
                  j+=1            
            
            if point_count == len(mat[0]):
                  del mat[i]
                  i = 0
                  point_count = 0
                  continue
            i+=1
            point_count = 0
            # print(mat)

      mat = transpose(mat)

      point_count = 0
      i = 0
      while i<len(mat):
            j = 0
            while j<len(mat[0]):
                  if(mat[i][j] == '.'):
                        point_count += 1
                  j+=1            
            
            if point_count == len(mat[0]):
                  del mat[i]
                  i = 0
                  point_count = 0
                  continue
            i+=1
            point_count = 0
            # print(mat)

      return transpose(mat)

if __name__ == '__main__':
    mat = get_input()
    mat2 = get_output(mat)

    print mat2

# del a[1]

Submission status: Runtime Error

Solution code:
def get_input():
      w = input()
      h = input()
      a = []
      for i in range(w):
            sub_a = []
            for j in range(h):
                  sub_a.append(raw_input())
            a.append(sub_a)
      return a

def transpose(mat):
      mat2 =[[row[i] for row in mat] for i in range(len(mat[0]))]
      return mat2

def get_output(mat):
      # done_flag = False
      point_count = 0
      i = 0
      while i<len(mat):
            j = 0
            while j<len(mat[0]):
                  if(mat[i][j] == '.'):
                        point_count += 1
                  j+=1            
            
            if point_count == len(mat[0]):
                  del mat[i]
                  i = 0
                  point_count = 0
                  continue
            i+=1
            point_count = 0
            print(mat)

      mat = transpose(mat)

      point_count = 0
      i = 0
      while i<len(mat):
            j = 0
            while j<len(mat[0]):
                  if(mat[i][j] == '.'):
                        point_count += 1
                  j+=1            
            
            if point_count == len(mat[0]):
                  del mat[i]
                  i = 0
                  point_count = 0
                  continue
            i+=1
            point_count = 0
            print(mat)

      return transpose(mat)

if __name__ == '__main__':
    mat = get_input()
    mat2 = get_output(mat)

    print mat2

# del a[1]