In Gridnavia, three languages are spoken: Arwegian, Banish, and Cwedish. Gridnavia consists of an
grid, where at least one language is spoken in each cell. It is known that each of the three languages is spoken in a non-empty connected subset of grid cells. Connected means that it is possible to get between any pair of cells by moving through adjacent cells, where two cells are said to be adjacent if they share a side.
You have made a survey to find where in Gridnavia each language is spoken. The following question was sent to every cell in the region: “Please indicate if one or several of the languages is spoken in your cell”. But due to a misprint, there were no choices after the question, so everyone just wrote “one” or “several”. So the only thing you know is for each cell whether exactly one, or more than one language is spoken in that cell.
To make the best out of the situation, you should find any division of the three languages that corresponds to the information.
输入描述:
The first line of input contains two integers n and m (1 ≤ n, m ≤ 200).
The following n lines each contain a string of length m, consisting of the characters 1 and 2.The jth character on the ith line is 1 if exactly one language is spoken in that cell, and 2 if atleast two languages are spoken.
输出描述:
If the languages can be divided according to the information, then output three copies of the grid.The first copy should consist of characters “A” and “.”, where the “A” indicates that Arwegian isspoken in that cell, and “.” indicates that it isn’t spoken. The following two grids should consistof characters “B” and “.”, and “C” and “.”, respectively, with the corresponding informationabout Banish and Cwedish.
Remember that the three regions have to be connected and non-empty, and every cell must bepart of some region. For readability, it is recommended to put empty lines in between the threegrids, but it is not necessary to do so. If there are multiple solutions any one will be accepted.
Otherwise, if there is no way to divide the languages, output “impossible”.
示例1
输出
复制
AAAA
...A
....
BB..
BBBB
...B
....
...C
CCCC