P6368 [COCI 2006/2007 #6] MAGIJA

Background

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

Description

As we all know, the back of a playing card is a rectangle. By drawing the perpendicular bisectors of its two sides, the rectangle can be divided into four equal parts. Al'Dimi Kartimi first draws the pattern in the upper-left part. The pattern has $r$ rows and $c$ columns, and consists of the characters `#` and `.`. After finishing, he mirrors this pattern across the vertical midline of the rectangle to draw the upper-right part. Then he mirrors the entire upper half across the horizontal midline to draw the lower half. After drawing, Al'Dimi Kartimi will intentionally make a small mistake so that he can identify which card back it is. Specifically, he chooses the character in row $x$, column $y$: if it is `#`, he changes it to `.`, otherwise he changes it to `#`. Below are three examples of card back patterns (the wrong character is highlighted in gray). ![](https://cdn.luogu.com.cn/upload/image_hosting/7p7lah31.png) Given the upper-left pattern and $x, y$, output the full pattern of the entire card back.

Input Format

The first line contains two integers, representing the number of rows $r$ and the number of columns $c$ of the upper-left pattern. Lines $2$ to $(r + 1)$ each contain a string of length $c$. The $j$-th character $s_{i, j}$ in line $(i + 1)$ represents the character in row $i$, column $j$ of the pattern. Line $(r + 2)$ contains two integers, representing the row $x$ and column $y$ of the small mistake.

Output Format

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

Explanation/Hint

#### Constraints For all test cases, it is guaranteed that: - $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](https://hsin.hr/coci/archive/2006_2007/) [CONTEST #6](https://hsin.hr/coci/archive/2006_2007/contest6_tasks.pdf) *T2 MAGIJA***。 Translated by ChatGPT 5