#P2191. Secret Love Letter
Secret Love Letter
Secret Love Letter
Little Z had two pieces of paper of size \(N \times N\): one transparent and one with letters. He painted some cells of the transparent paper black. Then he placed the transparent paper on top of the letter paper. His method of reading was as follows: for each overlay, read the letters that are visible (i.e. the cells where the transparent paper is not painted black) in row-major order (from top to bottom, and left to right). After the first reading, the transparent paper is rotated 90° clockwise and the process is repeated. In total, the transparent paper is laid four times (at 0°, 90°, 180°, and 270°). The final secret message is the concatenation of the four rounds of reading.
The correspondence between a cell in the rotated transparent paper and the original transparent paper is given by:
- 0°: \((r, c)\) corresponds to \((r, c)\).
- 90°: \((r, c)\) corresponds to \((N-1-c, r)\).
- 180°: \((r, c)\) corresponds to \((N-1-r, N-1-c)\).
- 270°: \((r, c)\) corresponds to \((c, N-1-r)\).
Your task is to simulate this process. Given the letter paper and the transparent paper (with '#' representing a black painted cell and '.' representing a transparent cell), output the secret message obtained by reading all four rounds in order. Note that the letter paper remains fixed and is always read in its original orientation.
inputFormat
The first line contains an integer \(N\) (\(1 \le N \le 1000\)) — the size of the papers.
The next \(N\) lines each contain \(N\) characters, representing the letter paper.
The following \(N\) lines each contain \(N\) characters, representing the transparent paper. Each character is either '#' (a painted black cell) or '.' (a transparent cell).
outputFormat
Output the secret message obtained by reading the visible letters in four rounds (0°, 90°, 180°, and 270°). The answer should be printed as a single string with no spaces or newlines.
sample
2
AB
CD
.#
#.
ADBCADBC