/
実行時間制限: 2 sec / メモリ制限: 1024 MiB
問題文
長さ 3W の文字列 S_1,\ldots,S_{3H} が与えられます。これらの文字列は . と # のみからなります。
文字列 S_i の j 文字目を S_{i,j} と表します。
以下の条件を満たす長さ W の文字列 T_1,\ldots,T_H を求めてください。
- 1\leq i \leq H、1\leq j \leq W を満たす全ての整数の組 (i,j) について、以下が成り立つ。
- S_{3i-2,3j-2}, S_{3i-2,3j-1}, S_{3i-2,3j}, S_{3i-1,3j-2}, S_{3i-1,3j-1}, S_{3i-1,3j}, S_{3i,3j-2}, S_{3i,3j-1}, S_{3i,3j} のうち
#が 5 個以上あれば T_i の j 文字目は#であり、そうでなければ.である。
- S_{3i-2,3j-2}, S_{3i-2,3j-1}, S_{3i-2,3j}, S_{3i-1,3j-2}, S_{3i-1,3j-1}, S_{3i-1,3j}, S_{3i,3j-2}, S_{3i,3j-1}, S_{3i,3j} のうち
制約
- 1\leq H,W \leq 50
- H,W は整数
- S_{i} は
.,#からなる長さ 3W の文字列
入力
入力は以下の形式で標準入力から与えられる。
H W
S_1
S_2
\vdots
S_{3H}
出力
問題文中の条件を満たす文字列 T_1,\ldots,T_H を改行区切りで出力せよ。
入力例 1
3 3 ...###... ...###... ...###... ######### ######### ######### ###...### ###...### ###...###
出力例 1
.#. ### #.#
例えば、S_{1,1}, S_{1,2}, S_{1,3}, S_{2,1}, S_{2,2}, S_{2,3}, S_{3,1}, S_{3,2}, S_{3,3} のうち # は 0 個なので、T_1 の 1 文字目は . になります。
入力例 2
3 4 ....###..... ...#####.... .########... ##########.. ###########. ############ ###...###### ##.....##### #.......####
出力例 2
.##. #### #.##
例えば、S_{1,1}, S_{1,2}, S_{1,3}, S_{2,1}, S_{2,2}, S_{2,3}, S_{3,1}, S_{3,2}, S_{3,3} のうち # は 2 個なので、T_1 の 1 文字目は . になります。
Problem Statement
There are length-3W strings S_1,\ldots,S_{3H}, each consisting of . and #.
Let S_{i,j} denote the j-th character of string S_i.
Find the strings T_1,\ldots,T_H, each of length W, such that:
- for all integer pairs (i,j) with 1\leq i \leq H and 1\leq j \leq W:
- the j-th character of T_i is
#if at least five of S_{3i-2,3j-2}, S_{3i-2,3j-1}, S_{3i-2,3j}, S_{3i-1,3j-2}, S_{3i-1,3j-1}, S_{3i-1,3j}, S_{3i,3j-2}, S_{3i,3j-1}, S_{3i,3j} are#; otherwise, it is..
- the j-th character of T_i is
Constraints
- 1\leq H,W \leq 50
- H and W are integers.
- S_{i} is a string of length 3W consisting of
.and#.
Input
The input is given from Standard Input in the following format:
H W
S_1
S_2
\vdots
S_{3H}
Output
Print the strings T_1,\ldots,T_H satisfying the condition in the problem statement, separated by newlines.
Sample Input 1
3 3 ...###... ...###... ...###... ######### ######### ######### ###...### ###...### ###...###
Sample Output 1
.#. ### #.#
For example, none of S_{1,1}, S_{1,2}, S_{1,3}, S_{2,1}, S_{2,2}, S_{2,3}, S_{3,1}, S_{3,2}, S_{3,3} is #, so the 1-st character of T_1 is ..
Sample Input 2
3 4 ....###..... ...#####.... .########... ##########.. ###########. ############ ###...###### ##.....##### #.......####
Sample Output 2
.##. #### #.##
For example, two of S_{1,1}, S_{1,2}, S_{1,3}, S_{2,1}, S_{2,2}, S_{2,3}, S_{3,1}, S_{3,2}, S_{3,3} are #, so the 1-st character of T_1 is ..