P29358 [洛谷] [COCI2006-2007#6] MAGIJA
普及
题目描述

Problem Background

Renowned magician Al'Dimi Kartimi needs your help to design the back pattern of his playing cards.

Problem Description

As is well known, the back of a playing card is a rectangle, which can be divided into four equal parts by drawing perpendicular bisectors on both sides.

Al'Dimi Kartimi first draws the pattern for the top-left part, which consists of $r$ rows and $m$ columns, composed of characters # and .. After drawing, he mirrors this pattern symmetrically along the vertical bisector of the rectangle to draw the top-right part. Then, he mirrors the entire upper part along the horizontal bisector of the rectangle to draw the lower part.

After drawing, Al'Dimi Kartimi intentionally makes a small mistake to help him identify which card it is. Specifically, he selects the character at the $x$-th row and $y$-th column, and if it is #, he changes it to ., otherwise, he changes it to #.

Below are three examples of back patterns (the erroneous character is highlighted in gray).

Given the pattern of the top-left part and the values of $x$ and $y$, please output the entire back pattern of the card.

Input Format

The first line contains two integers, representing the number of rows $r$ and columns $c$ of the top-left pattern.

From the second to the $(r + 1)$-th line, each line contains a string of length $c$, where the $j$-th character of the $(i + 1)$-th line $s_{i, j}$ represents the character in the $i$-th row and $j$-th column of the pattern.

The $(r + 2)$-th line contains two integers, representing the row $x$ and column $y$ where the small error is made.

Output Format

Output $2r$ lines, each containing a string of length $2c$, representing the entire back pattern.

Sample Input and Output

Sample Input #1

2 2
#.
.#
3 3

Sample Output #1

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

Sample Input #2

3 3
###
###
###
1 4

Sample Output #2

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

Sample Input #3

5 4
#.#.
#.##
#.##
....
.#.#
10 5

Sample Output #3

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

Notes

Data Size and Constraints

For all test cases, the following constraints apply:

  • $1 \leq r, c \leq 50$.
  • $1 \leq x \leq 2r$, $1 \leq y \leq 2c$.
  • $s_{i, j} \in \{\texttt \#, \texttt . \}$

Notes

This problem is translated from COCI2006-2007 CONTEST #6 T2 MAGIJA.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 2 #. .# 3 3
样例输出
#..# .##. .#.. #..#