#P4327. Peter Pan and Wendy Frames

    ID: 17573 Type: Default 1000ms 256MiB

Peter Pan and Wendy Frames

Peter Pan and Wendy Frames

In this problem you are given a string, and you must decorate the text by framing each letter in a diamond‐shaped frame. Normally, each letter is framed with a Peter Pan frame:

..#..
.#.#.
#.X.#
.#.#.
..#..

However, every third letter (i.e. the 3rd, 6th, 9th, … letter) is framed with a Wendy frame instead:

..*..
.*.*.
*.X.*
.*.*.
..*..

When the frames are placed side‐by‐side, the frames interleave: they share columns, and if a Wendy frame interleaves with a Peter Pan frame the Wendy frame (being nicer) is drawn on top. In other words, for overlapping positions, the following precedence is used:

  • Wendy frame borders (*) and letters (A–Z) have higher priority.
  • Peter Pan frame borders (#) are used only if there is no overriding Wendy border or letter.

The frame for a letter is always 5 rows high. When framing a string of length \(n\), the resulting decorated text will have a height of 5 and a width of \(4n+1\). The leftmost frame is placed starting at the left edge, and for every subsequent letter the corresponding frame starts 4 columns to the right (i.e. the frames interleave by one column).

For example, if the input is ABC, note that the 3rd letter uses the Wendy frame while the first two use the Peter Pan frame. The final output will be computed by overlaying each frame’s contribution (using the above priority rule) into a grid and then printing the grid row by row.

Note: When a frame is applied, the cell in the center of the 5 \(\times\) 5 block is replaced by the corresponding letter.

inputFormat

The input consists of a single line that contains a string of uppercase letters (A–Z) with length \(n\) (\(1 \le n \le 100\)).

outputFormat

Output the decorated frame which has 5 rows. Each row should contain exactly \(4n+1\) characters.

sample

A
..#..

.#.#. #.A.# .#.#. ..#..

</p>