Tiny Puzzle#1923

Tiny Puzzle

2 seconds
256 megabytes
Very hard

You've decided to create a puzzle as part of your company's "re-branding" campaign. In the box, this puzzle will represent the new logo of your company, meaning it will be a set of connected unit squares on a rectangular grid. However, these squares are not necessarily all joined together; they may form several connected parts (but you cannot split a square in the middle). The objective of the puzzle is to rearrange these parts so that they form a 3 \times 3 square. Only sliding parts is allowed—rotating or flipping them is not permitted.

To make the puzzle more challenging, you need as few parts as possible. Given the logo, determine how many parts are needed and how to rearrange them into a 3 \times 3 square.

Every use of the word "connected" means side-by-side connectedness.

Input

The first line contains two integers and . The next lines each contain characters, describing your logo. Each character will be either "." (dot), indicating an empty square, or "X" (capital letter X), indicating a square occupied by the logo. All the "X" characters form a connected figure, with exactly "X" in the input. The first row, last row, first column, and last column each contain at least one "X". In other words, there are no unnecessary empty rows or columns at the edges of the grid.

Output

On the first line, output the required number of parts . Then output one possible rearrangement: in the next lines, output your logo with all "X" replaced by the first capital letters of the English alphabet, so that each letter represents one part. Then output an empty line, followed by lines each with characters, showing the same parts shifted so they form a 3 \times 3 square.

All parts must be connected, and must be as small as possible. If there are multiple possible solutions, output any one.

Examples

Example 1

Loading
Loading