luogu#P6368. [COCI 2006/2007 #6] MAGIJA
[COCI 2006/2007 #6] MAGIJA
Background
The famous magician Al'Dimi Kartimi needs your help to design the back pattern of his playing cards.
Problem 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 rows and 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 , column : 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).

Given the upper-left pattern and , output the full pattern of the entire card back.
Input Format
The first line contains two integers, representing the number of rows and the number of columns of the upper-left pattern.
Lines to each contain a string of length . The -th character in line represents the character in row , column of the pattern.
Line contains two integers, representing the row and column of the small mistake.
Output Format
Output lines, each a string of length , representing the full back pattern.
2 2
#.
.#
3 3
#..#
.##.
.#..
#..#
3 3
###
###
###
1 4
###.##
######
######
######
######
######
5 4
#.#.
#.##
#.##
....
.#.#
10 5
#.#..#.#
#.####.#
#.####.#
........
.#.##.#.
.#.##.#.
........
#.####.#
#.####.#
#.#.##.#
Hint
Constraints
For all test cases, it is guaranteed that:
- .
- , .
Notes
This problem is translated from COCI2006-2007 CONTEST #6 T2 MAGIJA。
Translated by ChatGPT 5