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:
# -*- coding: utf-8 -*-

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

a = [list(input()) for _ in range(h)]

a_new = []
for row in a:
    cache = set(row)
    if (len(cache) == 1) and (row[0] == "."):
        pass
    else:
        a_new.append(row)

n_h = len(a_new)
n_w = len(a_new[0])

b_new = [["" for _ in range(n_h)] for _ in range(n_w)]

for i in range(n_h):
    for j in range(n_w):
        b_new[j][i]=a_new[i][j]


a = b_new

a_new = []
for row in a:
    cache = set(row)
    if (len(cache) == 1) and (row[0] == "."):
        pass
    else:
        a_new.append(row)


n_h = len(a_new)
n_w = len(a_new[0])

b_new = [["" for _ in range(n_h)] for _ in range(n_w)]

for i in range(n_h):
    for j in range(n_w):
        b_new[j][i]=a_new[i][j]


ans = ""

for i in range(n_h):
    for j in range(n_w):
        ans += b_new[i][j]
    ans += "\n"

print(ans)

Submission status: Runtime Error

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


delete_candidate = []
for i in range(H):
        flag = False
        for j in maze[i]:
                if j == "#":
                        flag = True
                        continue
        if flag == False:
                delete_candidate.append(i)

for i in delete_candidate:
        del maze[i]

delete_candidate = []
for j in range(W):
        flag = False
        for i in range(len(maze)):
                if maze[i][j] == "#":
                        flag = True
                        continue
        if flag == False:
                delete_candidate.append(j)


for i in range(len(maze)):
        for j in range(len(maze[i])):  
                if j in delete_candidate:
                        continue
                print(maze[i][j], end = "")
        print("")

Submission status: Runtime Error

Solution code:
a=[input() for i in range(h)]
b=[]
for i in a:
  if "#" in i:
    b.append(i)
for i in range(w):
  for j in range(len(b)):
    if b[j][i] == "#":
      break
    elif j == len(b)-1:
      for k in range(len(b)):
        print(b[k][:i],b[k][i+1:],sep="")

Submission status: Runtime Error

Solution code:
h,w = map(int,input().split())
a=[input() for i in range(h)]
b=[]
c=[]
for i in a:
  if "#" in i:
    b.append(i)
for i in range(w):
  for j in range(len(b)):
    if b[j][i] == "#":
      break
    elif j = h-1:
      for k in b:
        del k[j]
print(b)

Submission status: Runtime Error

Solution code:
h,w=map(int,input().split())
a=[]
for i in range(h):
    li=str(input())
    if len(set(li))!=1:
        a.append(li)
cnt=[]
b=[]
for j in range(w):
    for k in range(len(a)):
        b.append(a[k][j])
    if len(set(b))==2 or b[0]=="#":
      cnt.append(j)
    b=[]            
ans=""
for m in range(len(a)):
  for l in cnt:
    ans+=a[m][l]
  print(ans)
  ans=""

Submission status: Runtime Error

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

b = []
for i in range(W):
  bi = [""] * W
  for j in range(len(a)):
    if j == len(a) - 1 and "#" in a[j - 2][i] + a[j - 1][i] + a[j][i]:
      b.append(a[j - 2][i] + a[j - 1][i] + a[j][i])
      
for i in range(len(b)):
  ans = 0
  for j in range(len(b[0])):
    ans = b[j - 2][i] + b[j - 1][i] + b[j][i]
  print(ans)

Submission status: Runtime Error

Solution code:
h, w = list(map(int, input().split()))
grid = []
for i in range(h):
    temp = list(input())
    if "#" in temp:
        grid.append(temp)
    else:
        h -= 1
i = 0
while i < len(grid[0]):
    for j in range(h):
        if grid[j][i] == "#":
            i += 1
            break
        if j == h - 1:
            for k in range(h):
                del grid[k][i]
for i in range(len(grid[0])):
    print("".join(grid[i]))

Submission status: Runtime Error

Solution code:
import numpy as np
h, w = list(map(int, input().split()))
grid = []
for i in range(h):
    temp = list(input())
    if "#" in temp:
        grid.append(temp)
    else:
        h -= 1
i = 0
while i < len(grid[0]):
    for j in range(h):
        if grid[j][i] == "#":
            i += 1
            break
        if j == h - 1:
            for k in range(h):
                del grid[k][i]
for i in range(len(grid[0])):
    print("".join(grid[i]))

Submission status: Runtime Error

Solution code:
from __future__ import print_function
# import numpy as np
# import numpypy as np
import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd

def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace

from queue import PriorityQueue as pq

def reduce(p, q):
    common = fractions.gcd(p, q)
    return (p//common , q//common )
# from itertools import accumulate
# from collections import deque

import random


def main():
    H,W = map(int, input().strip().split()) # H行 W列
    G=[]
    for i_row in range(H):
        G.append(input().strip())
    eprint("graph G:")
    eprint(G)

    l_flag_row_all_dot_flag=[ 1 for _ in range(W) ]
    for i_row in range(H):
        for j_col in range(W):
            if G[i_row][j_col]!=".":
                l_flag_row_all_dot_flag[i_row]=0


    l_flag_col_all_dot_flag=[ 1 for _ in range(W) ]
    for j_col in range(W):
        for i_row in range(H):
            if G[i_row][j_col]!=".":
                l_flag_col_all_dot_flag[j_col]=0

    for i_row in range(H):
        if l_flag_row_all_dot_flag[i_row]==1:
            continue
        for j_col in range(W):
            if l_flag_col_all_dot_flag[j_col]==1:
                continue
            print(G[i_row][j_col],end="")
        print()






    # for i_row in range(H):      # H is length of row
    #     if G[i_row] == str(["."* W ]):
    #         G.pop(i_row)

    # all_dot_flag=1
    # for j_col in range(W):      # W は列の長さ
    #     for i_row in range(H):  # H は行の長さ
    #         G[i_row][j_col] != "."
    #         failure_flag=0
    #     if all_dot_flag==1:
    #         for ii in range(H):
    #             G.pop()
    return

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
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 i 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())
grid = []
for i in range(H):
    a = input()
    l = []
    for i in a:
        l.append(i)
    grid.append(l)
grid_1 = []
for i,job in enumerate(grid):
    count = 0
    for j in job:
        if(j == "."):
            count += 1
    if(count != W):
        grid_1.append(job)
count = 0
for i in delete:
    grid.pop(i-count)
    count += 1
grid_3 = []
for Row in zip(*grid_1):
    w = len(Row)
    count = 0
    for j in Row:
        if(j == "."):
            count += 1
    if(count != w):
        grid_3.append(Row)
for Row in zip(*grid_3):
    ans = ""
    for j in Row:
        ans += j
    print(ans)

Submission status: Runtime Error

Solution code:
H,W = map(int,input().split())
grid = []
for i in range(H):
    a,b,c,d = input()
    l = [a,b,c,d]
    grid.append(l)
delete = []
grid_1 = []
for i,job in enumerate(grid):
    count = 0
    for j in job:
        if(j == "."):
            count += 1
    if(count != W):
        grid_1.append(job)
count = 0
for i in delete:
    grid.pop(i-count)
    count += 1
grid_3 = []
for Row in zip(*grid_1):
    w = len(Row)
    count = 0
    for j in Row:
        if(j == "."):
            count += 1
    if(count != w):
        grid_3.append(Row)
for Row in zip(*grid_3):
    ans = ""
    for j in Row:
        ans += j
    print(ans)

Submission status: Runtime Error

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

for i in range(h):
  a.append(list(map(int, input().split())))

h_blank = [False]*h
w_blank = [False]*w
for i in range(h):
  blank = True
  for j in range(w):
    if a[i][j] == '#':
      blank = False
      break
  if blank:
    h_blank[i] = True

for i in range(w):
  blank = True
  for j in range(h):
    if a[j][i] == '#':
      blank = False
      break
  if blank:
    w_blank[i] = True

for i in range(h):
  for j in range(w):
    if h_blank[i] or w_blank[j]:
      continue
    print(a[i][j])

Submission status: Runtime Error

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

for i in range(h):
  a.append(list(map(int, input().split())))

h_blank = [False]*h
w_blank = [False]*w
for i in range(h):
  blank = True
  for j in range(w):
    if a[i][j] == '#':
      blank = False
      break
  if blank:
    h_blank[i] = True

for i in range(w):
  blank = True
  for j in range(h):
    if a[j][i] == '#':
      blank = False
      break
  if blank:
    w_blank[i] = True

for i in range(h):
  for j in range(w):
    if h_blank[i] or w_blank[j]:
      continue
    print(a[i][]j)

Submission status: Runtime Error

Solution code:
c,r=map(int,input().split())
lst=[list(input())] for _ in range(c)]
print(c,r,lst)
print(all([i == "." for i in lst]))

Submission status: Runtime Error

Solution code:
h,w=map(int,input().split())
a=[]
for i in range(h):
    a.append(list(input()))
j=0
lis=[]
while j<len(a):
    if '#' not in set(a[j]):
        a.remove(a[j])
    j+=1
for k in range(len(a)):
    for l in range(w):
        if a[k][l]=='.':
            c=0
            while c<len(a):
                if a[c][l]!='.':
                    break
                if c==len(a)-1 and l not in set(lis):
                    lis.append(l)
                c+=1
ans=''
#print(lis)
tmp=0

for o in range(len(lis)):
    tmp=lis[o]
    for s in range(len(a)):
        del a[s][tmp]
for q in range(len(a)):
    for e in range(len(a[0])):
        ans+=a[q][e]
    print(ans)
    ans=''

Submission status: Runtime Error

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

h_score=[0]*h
w_score=[0]*w
for i in range(h):
    for j in range(w):
        if a[i][j]=='.':
            h_score[j]+=1
            w_score[i]+=1

for i in range(h):
    if h_score[i]==h:
        a=np.delete(a,i,1)
for i in range(w):
    if w_score[i]==w:
        a=np.delete(a,i,0)

for i in a:#行列を入力と同じ形式で出力
    print(*i)

Submission status: Runtime Error

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

HW_list = []
for i in range(H):
    x = input()
    char_list = list(x)
    if "#" in char_list:
        HW_list.append(char_list)
    else:
        pass

i = 0
while True:
    count = 0
    for j in range(len(HW_list)):
        if HW_list[j][i] == ".":
            count += 1
        
    if count == len(HW_list):
        for j in range(len(HW_list)):
            del HW_list[j][i]
    else:
        i += 1
    if i > len(HW_list) - 1:
        break
    
for j in range(len(HW_list)):
    print("".join(HW_list[j]))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import numpy as np
H,W = map(int,input().split())
h = [0]*H
w = [0]*W
l = [list(input()) for i in range(H)]
for i in range(H):
    if all([i=='.' for i in l[i][:]]):
        h[i]=1
for j in range(W):
    if all([j=='.' for j in np.array(l).T[j][:]]):
        w[j]=1
for i in range(H):
    for j in range(W):
        if h[i]==0 and w[j]==0:
            print(l[i][j],end='')
    if h[i]==0:
        print()

Submission status: Runtime Error

Solution code:
H,W = map(int,input().split())
S=[]
for i in range(H):
    S.append(input())
T=[]
for i in range(H):
    T.append([])
    for j in range(W):
        T[-1].append(int(S[i][j]=='#'))

#横
for i in range(H):
    if T[i].count(1)==0:
        for j in range(W):
            T[i][j]=2

#縦
for i in range(W):
    tate=0
    for j in range(H):
        if T[j][i]!=1:
            tate+=1
    if tate==H:
        for j in range(H):
            T[j][i]=2

A=[]
for i in range(H):
    A.append([])
    for j in range(W):
        if T[i][j]!=2:
            A[i].append('#.'[T[i][j]==0])

for i in range(H-1):
    if len(A[i])==0:
        A.pop(i)

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

Submission status: Runtime Error

Solution code:
h,w=map(int,input().split())
a=[]
for i in range(h):
  s=input()
  if "#" in s:
    a.append([s])
h=len(a)
b=[]
for i in range(w):
  s=""
  for j in range(h):
    s+=a[j][0][i]
  if "#" in s:
    b.append([s])
w=len(b)
for i in range(w):
  s=""
  for j in range(h):
    s+=b[j][0][i]
  print(s)

Submission status: Runtime Error

Solution code:
h,w = map(int,input().split())
li,li2,li3 = [],[],[]
for i in range(h):
    li.append(list(input()))
li = [x for x in li if "#"  in x]

for i in range(w):
    li2.append([])
    for j in range(len(li)):
        li2[-1].append(li[j][i])
li2 = [x for x in li2 if "#"  in x]
for i in range(len(li2)):
    li3.append([])
    for j in range(len(li2[i])):
        li3[-1].append(li2[j][i])
for i in range(len(li3)):
    print("".join(li3[i]))

Submission status: Runtime Error

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

for _ in range(H):
    Data1.append(s)

hdata = {}
wdata = {}

for h in range(H):
    for w in range(W):
        if Data1[h][w] == '#':
            hdata.add(h)
            wdata.add(w)

for h in range(H):
    for w in range(W):
        if h in hdata or w in wdata:
            print(Data[h][w],end='')

Submission status: Runtime Error

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

l1=[i for i in a if '#' in i]
l2=[i for i in zip(*l1) if '#' in i]
for i in zip(*l2):
    print(''.join(i))

Submission status: Runtime Error

Solution code:
import numpy as np
H,W=map(int,input().split())
List=[list(input().split()) for i in range(H)]
M=np.array(List)
for i in range(H-1):
  if "#" not in M[i]:
    M=np.delete(M,i,0)
    for j in range(W-1):
      if "#" not in M[: , j]:
        M=np.delete(M,j,1)
S=M.tolist()
for a in S:
    print(*a)

Submission status: Runtime Error

Solution code:
H,W=map(int,input().split())
List=[list(input().split()) for i in range(H)]
for i in range(H):
  if "#" not in List[i]:
    List.pop(i)
    
    for j in range(W):
      if "#" not in [x[j] for x in List]:
        List.pop[x[j] for x in List]
print(List)

Submission status: Runtime Error

Solution code:
rows, cols = map(int, input().split())
mat = [input() for _ in range(rows)]

print_row = [False for _ in range(rows)]
print_col = [False for _ in range(cols)]

for i in range(rows):
  for j in range(cols):
    if mat[i][j] == '#':
      print_row[i] = True
      print_col[i] = True
      
for i in range(rows):
  for j in range(cols):
    if print_row[i] or print_col[j]:
      print(mat[i][j], end="")
  print()

Submission status: Runtime Error

Solution code:
H,W = [int(x) for x in input().split()]
ans = []
for i in range(H):
  cnt= 0
  S = list(input())
  for j in range(W):
    if S[j]==".":
      cnt +=1
  if cnt!=W:
    ans.append(S)
ans1 = []
for j in range(len(ans[0])):
  cnt = 0
  for i in range(len(ans)):
    if ans[i][j]==".":
      cnt+=1
  if cnt ==len(ans):
    ans1.append(j)
for i in range(len(ans)):
  for j in ans1:
    ans[i][j]=0
for i in range(len(ans)):
  for j in range(len(ans[0])):
    if ans[i][j] !=0:
    	print(ans[i][j],end"")
  print()

Submission status: Runtime Error

Solution code:
    h, w = map(int, input().split())
    a = []
    for _ in range(h):
        l = input()
        if l != '.'*w:
            a.append(l)
    col = []
    h = len(a)
    for i in range(w):
        if a[0][i] == '.':
            for j in range(1,h):
                if a[j][i] != '.':
                    col.append(i)
                    break
        else:
            col.append(i)
    for l in a:
        ll = ''
        for i in col:
            ll += l[i]
        print(ll)

h, w = map(int, input().split())
a = []
for _ in range(h):
    l = input()
    if l != '.'*w:
        a.append(l)
col = []
h = len(a)
for i in range(w):
    if a[0][i] == '.':
        for j in range(1,h):
            if a[j][i] != '.':
                col.append(i)
                break
    else:
        col.append(i)
for l in a:
    ll = ''
    for i in col:
        ll += l[i]
    print(ll)

Submission status: Runtime Error

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

def h_remove():
  pop_list = []
  h_c = 0
  pop_flag = False
  global h, w, lis
  while h_c < h:
    if lis[h_c].count("#") == w  or  lis[h_c].count(".") == w:
      lis.pop(h_c)
      h -= 1
      pop_flag = True
    else:
      h_c += 1
  return pop_flag

def transpose(list):
  return [[arr_w[i] for arr_w in list] for i in range(len(list[0]))]

def w_remove():
  global h, w, lis
  lis = transpose(lis)
  h, w = w, h
  pop_flag = h_remove()
  lis = transpose(lis)
  h, w = w, h
  return pop_flag

lis = transpose(transpose(lis))

pop_h, pop_w = True, True
while (pop_h == True) or (pop_w == True):
  pop_h = h_remove()
  pop_w = w_remove()
print(lis)

Submission status: Runtime Error

Solution code:
H, W = map(int,input().split())
a=[list(input()) for i in range(H)]
#yoko
while a.count(["."]*len(a[0]))>0:
    a.remove(["."]*len(a[0]))

a_t = tenchi(a)
while a_t.count(["."]*len(a_t[0]))>0:
    a_t.remove(["."]*len(a_t[0]))
ans = tenchi(a_t)
for i in range(len(ans)):
    ansa = "".join(ans[i])
    print(ansa)

def tenchi(gr):
    gr_t=[[0]*len(gr) for i in range(len(gr[0]))]
    for i in range(len(gr)):
        for j in range(len(gr[i])):
            gr_t[j][i] = gr[i][j]
    return gr_t

Submission status: Runtime Error

Solution code:
H, W = map(int,input().split())
a=[list(input()) for i in range(H)]
for i in range(1,H):
    if a[-i]==["."]*W:
        a.pop(-i)
a_t = tenchi(a)
for i in range(1,len(a_t)):
    if a_t[-i]==["."]*len(a):
        a_t.pop(-i)
ans = tenchi(a_t)
for i in range(len(ans)):
    ansa = "".join(ans[i])
    print(ansa)

def tenchi(gr):
    gr_t=[[0]*len(gr) for i in range(len(gr[0]))]
    for i in range(len(gr)):
        for j in range(len(gr[i])):
            gr_t[j][i] = gr[i][j]
    return gr_t

Submission status: Runtime Error

Solution code:
H, W = map(int,input().split())
a=[list(input()) for i in range(H)]
#yoko
for i in range(1,H):
    if a[-i]==["."]*W:
        a.pop(-i)
a_t = tenchi(a)
for i in range(1,len(a_t)):
    if a_t[-i]==["."]*len(a):
        a_t.pop(-i)
ans = tenchi(a_t)
for i in range(len(ans)):
    ansa = "".join(ans[i])
    print(ansa)

def tenchi(gr):
    gr_t=[[0]*len(gr) for i in range(len(gr[0]))]
    for i in range(len(gr)):
        for j in range(len(gr[i])):
            gr_t[j][i] = gr[i][j]
    return gr_t

Submission status: Runtime Error

Solution code:
import sys
H,W = map(int,input().split())
a = [[c for c in l.strip()] for l in sys.stdin]
n = [] #行の情報
m = [] #列の情報
new = []
mew = []
for j in range(W):
  for i in range(H):
    t = a[i].count(".")
    if t == W:
      if j == 0:
        n.append(i)
    new.append(a[i][j])
  else:
    mew.append(new)
    new =[]
  if mew[j].count(".") == H:
    m.append(j)

for k in n:
  a.pop(k)
for l in range(len(a)):
  for o in m:
    a[l].pop(o)
    print("".join(a[l]))

Submission status: Runtime Error

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

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


#行に着目
dl = []

for i in range(h):
    if all(j =='.' for j in m[i]):
        dl.append(int(i))

if dl:
    for i in dl:
        del m[i]

#転置して同様
m = list(zip(*m)) 
if m:
    dl = []
    for i in range(w):
        if all(j =='.' for j in m[i]):
            dl.append(int(i))

    if dl:
        for i in range(len(dl)):
            del m[dl[len(dl)-i-1]]
            


#転置して元に戻す
m = list(zip(*m))


#出力
for i in range(len(m)):
    m[i] = ''.join(m[i])
    print(m[i])

Submission status: Runtime Error

Solution code:
import numpy as np
h,w = map(int,input().split())
a = [input() for i in range(h)]
d = "."
c = 0

for i in range(h):
  if len(set(a[i])) == 1 and a[i][0] == d:
    a.remove(a[i])

at = np.array(a)
tr = at.T

for i in range(w):
  if len(set(tr[i])) == 1 and tr[i][0] == d:
    a.remove(tr[i])
    
att = np.array(tr)
trr = att.T

for j in range(len(trr)):
  print("".join(trr[j]))

Submission status: Runtime Error

Solution code:
h,w = map(int,input().split())
board = []
checkX = [False]*w
checkY = [False]*h
for i in range(h):
    board.append(input())

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

Submission status: Runtime Error

Solution code:
h,w = map(int,input().split())
board = []
checkX = [False]*w
checkY = [False]*h
for i in range(h):
    board.append(input())

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

Submission status: Runtime Error

Solution code:
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 hl:
    for j in wl:
        print(l[i][j],end='')
    print()

Submission status: Runtime Error

Solution code:
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 hl:
    for j in wl:
        print(l[i][j],end='')
    print(/n)

Submission status: Runtime Error

Solution code:
miss

Submission status: Runtime Error

Solution code:
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:
            tateH,W=map(int,input().split())

Submission status: Runtime Error

Solution code:

h,w=map(int,input().split())
a=[]
for i in range(h):
	d=input()
	if d.count("#")!=0:
		a.append(d)
ss=0
for i in range(w-ss-1):
	cnt=0
	for j in range(len(a)):
		if a[j][i]=="#":
			cnt+=1
	if cnt==0:
		for jj in range(len(a)):
			a[jj]=a[jj][:i]+a[jj][i+1:]
			ss+=1
for i in range(len(a)):
	print(a[i])

Submission status: Runtime Error

Solution code:
import sys
targetlist = []
inphead = input()
num = inphead.split(' ')
i = int(num[0])
j = int(num[1])

for i in range(i):
	smalllist = list(input())
	targetlist.append(smalllist)

if targetlist:
	deletelist = []
	for row in range(i+1):
		if (all((elem == '.') for elem in targetlist[row])) or (all((elem == '#') for elem in targetlist[row])):
			deletelist.append(row)
	for d in reversed(deletelist):
		targetlist.pop(d)
	i = len(targetlist)
	deletelistcol = []
	for col in range(j):
		templist = []
		for row in range(i):
			templist.append(targetlist[row][col])
		if all((elem == '.') for elem in templist):
			deletelistcol.append(col)
	for d in reversed(deletelistcol):
		for row in range(i):
			targetlist[row].pop(d)
	j = len(targetlist[0])



for rowlist in targetlist:
	result = ''
	for elem in rowlist:
		result += elem
	print(result)

Submission status: Runtime Error

Solution code:
import numpy as np
h, w = list(map(int, input().split()))
loc_array = [list(input().replace("#", "1").replace(".", "0")) for _ in range(h)]
loc_array = np.array([list(map(int, l)) for l in loc_array])
row_sum = loc_array.sum(axis=1)
col_sum = loc_array.sum(axis=0)
while 0 in row_sum or 0 in col_sum:
  for i, r in enumerate(row_sum):
    if r == 0:
      loc_array = np.delete(loc_array, i, axis=0)
  for i, c in enumerate(col_sum):
    if c == 0:
      loc_array = np.delete(loc_array, i, axis=1)
  row_sum = loc_array.sum(axis=1)
  col_sum = loc_array.sum(axis=0)

loc_str = [list(map(str, loc_array[i,:])) for i in range(loc_array.shape[0])]
loc_str = ["".join(l).replace("1", "#").replace("0", ".") for l in loc_str]
for l in loc_str:
  print(l)

Submission status: Runtime Error

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

L = []
R = []

for i in range(H):
  R_cnt = 0
  for j in range(W):
    if A[i][j] == '.':
      R_cnt += 1
  if R_cnt == W:
    R.append(i)

for j in range(W):
  L_cnt = 0
  for i in range(H):
    if A[i][j] == '.':
      L_cnt += 1
  if L_cnt == H:
    L.append(j)

for i in range(H):
  S = []
  for j in range(W):
    if i in R or j in L:
      break
    else:
      S.append(A[i][j])
  print(' '.join(S))

Submission status: Runtime Error

Solution code:
h,w = map(int,input().split())
li = []
for i in range(h):
    a = list(input().split())
    li.append(a)
li2 = li.copy()
c = 0
for i in range(h):
    for j in range(w):
        c = 0
        if li[i][j] == ".":
            continue
        elif li[i][j] == "#":
            c = 1
            break
    if c == 0:
        li[i] = ["a"] * w
d = 0
n = []
for i in range(w):
    for j in range(h):
        d = 0
        if li[j][i] == "." or li[j][i] == "a":
            continue
        else:
            d = 1
            break
    if d == 0:
        n.append(i)
for i in n:
    for j in range(h):
        li[j][i] = "a"

for i in range(h):
    grid = ""
    for x in li[i]:
        if x != "a":
            grid += x
    print(grid)

Submission status: Runtime Error

Solution code:
h,w=map(int,input().split())
l=[input() for i in range(h)]
li=[]
li4=[]
for L in l:
  if (L=="."*w):
    continue
  li.append(L)
  li2=[list(x) for x in zip(*li)]
  ll=len(li2[0])
for i in range(h):
  li3=[''.join(li2[i])]
  for L in li3:
    if (L=="."*ll):
      continue
    li4.append(L)
    li5=[list(x) for x in zip(*li4)]
for i in range(ll):
  li6=[''.join(li5[i])]
  for L in li6:
    print(L)

Submission status: Runtime Error

Solution code:
H,W = map(int,input().split())
l = [list(input()) for i in range(H)]
#print(H,W,l)

w_del = []
h_del = []
for i in range(W):
    flag = 0
    for j in range(H):
        if l[j][i] == "#":
            flag = 1
    if flag == 0:
        w_del.append(i)
for x in w_del:
    for i in range(H):
        del l[i][x]

W = len(l[0])
for i in range(H):
    flag = 0
    for j in range(W):
        if l[i][j] == "#":
            flag = 1
    if flag == 0:
        h_del.append(i)
for x in h_del:
    del l[x]

for i in l:
    for x in i:
        print(x,end="")
    print()

Submission status: Runtime Error

Solution code:
ｖH, W = map(int, input().split())
a = []
for i in range(H):
    s = input()
    if s != '.'*W:
        a.append(s)
ls = []
for i in range(W):
    b = ''
    for j in range(len(a)):
        b += a[j][i]
    if b == '.'*len(a):
        ls.append(i)
ans = []
for i in range(W):
    s = ''
    for j in range(len(a)):
        if i in ls:
            continue
        else:
            s += a[j][i]
    ans.append(s)
print(*ans, sep='\n')

Submission status: Runtime Error

Solution code:
H, W = map(int, input().split())
a = []
for i in range(H):
    s = input()
    if s != '.'*W:
        a.append(s)
ls = []
for i in range(W):
    b = ''
    for j in range(len(a)):
        b += a[j][i]
    if b == '.'*len(a):
        ls.append(i)
ans = []
for i in range(W):
    s = ''
    for j in range(len(a)):
        if i in ls:
            continu
        else:
            s += a[j][i]
    ans.append(s)
print(*ans, sep='\n')

Submission status: Runtime Error

Solution code:
H, W = map(int, input().split())
a = []
for i in range(H):
    s = input()
    if s != '.'*W:
        a.append(input())
ls = []
for i in range(W):
    cur = 0
    for j in range(len(a)):
        if a[j][i] == '.':
            cur += 1
    if cur == len(a):
        ls.append(i)
ans = []
for i in ls:
    for s in a:
        ans.append(s[:i] + s[i+1:])
print(*ans, sep='\n')

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[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 = [list(input()) for i in range(W)]
a = [x for x in a if '#' in x]

aT = list(zip(*a))
aT = [x for x in aT if '#' in x]
ans = list(zip(*aT))

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

Submission status: Runtime Error

Solution code:
h,w=map(int,input().split())
a=[]
for i in range(h):
  aa=list(input())
  if "#" not in aa:
    continue
  else:
    a.append(aa)
for i in range(w):
  c=0
  for j in range(len(a)):
    if a[j][i]=="#":
      c+=1
  if c==0:
    for j in range(len(a)):
      del a[j][i]
for i in range(len(a)):
  print("".join(a[i]))